diff --git a/.env.example b/.env.example index afaf7a0..26ade7f 100644 --- a/.env.example +++ b/.env.example @@ -25,11 +25,14 @@ SHARED_TOKEN= # 令牌列表文件路径(已弃用) # TOKEN_LIST_FILE=.tokens -# (实验性)是否启用慢速池(true/false) +# 是否启用慢速池(true/false)(已失效) ENABLE_SLOW_POOL=false -# 允许claude开头的模型请求绕过内置模型限制(true/false) -PASS_ANY_CLAUDE=false +# 允许claude开头的模型请求绕过内置模型限制(true/false)(已弃用) +# PASS_ANY_CLAUDE=false + +# (实验性)是否启用长上下文模式(true/false) +ENABLE_LONG_CONTEXT=false # 图片处理能力配置 # 可选值: diff --git a/Cargo.lock b/Cargo.lock index f6594cd..554f0d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy 0.7.35", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -52,6 +64,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "android-tzdata" version = "0.1.1" @@ -75,9 +93,9 @@ checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "async-compression" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310c9bcae737a48ef5cdee3174184e6d548b292739ede61a1f955ef76a738861" +checksum = "c0cf008e5e1a9e9e22a7d3c9a4992e21a350290069e36d8fb72304ed17e8f2d2" dependencies = [ "brotli", "flate2", @@ -274,9 +292,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.16" +version = "1.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" +checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" dependencies = [ "shlex", ] @@ -369,6 +387,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + [[package]] name = "crypto-common" version = "0.1.6" @@ -381,7 +405,7 @@ dependencies = [ [[package]] name = "cursor-api" -version = "0.1.3-rc.5.2.2" +version = "0.1.3-rc.5.2.3" dependencies = [ "axum", "base64", @@ -394,6 +418,7 @@ dependencies = [ "gif", "hex", "image", + "lasso", "memmap2", "parking_lot", "paste", @@ -415,6 +440,20 @@ dependencies = [ "uuid", ] +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "digest" version = "0.10.7" @@ -639,14 +678,16 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", + "js-sys", "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets 0.52.6", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", ] [[package]] @@ -690,7 +731,17 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", ] [[package]] @@ -1045,6 +1096,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lasso" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e14eda50a3494b3bf7b9ce51c52434a761e383d7238ce1dd5dcec2fbc13e9fb" +dependencies = [ + "dashmap", + "hashbrown 0.14.5", +] + [[package]] name = "libc" version = "0.2.171" @@ -1309,7 +1370,7 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy", + "zerocopy 0.8.24", ] [[package]] @@ -1431,11 +1492,12 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quinn" -version = "0.11.6" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" +checksum = "c3bd15a6f2967aef83887dcb9fec0014580467e33720d073560cf015a5683012" dependencies = [ "bytes", + "cfg_aliases", "pin-project-lite", "quinn-proto", "quinn-udp", @@ -1445,17 +1507,18 @@ dependencies = [ "thiserror 2.0.12", "tokio", "tracing", + "web-time", ] [[package]] name = "quinn-proto" -version = "0.11.9" +version = "0.11.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" +checksum = "b820744eb4dc9b57a3398183639c511b5a26d2ed702cedd3febaa1393caa22cc" dependencies = [ "bytes", - "getrandom 0.2.15", - "rand 0.8.5", + "getrandom 0.3.2", + "rand 0.9.0", "ring", "rustc-hash", "rustls", @@ -1490,6 +1553,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "radium" version = "0.7.0" @@ -1511,8 +1580,6 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "libc", - "rand_chacha 0.3.1", "rand_core 0.6.4", ] @@ -1522,19 +1589,9 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ - "rand_chacha 0.9.0", + "rand_chacha", "rand_core 0.9.3", - "zerocopy", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", + "zerocopy 0.8.24", ] [[package]] @@ -1552,9 +1609,6 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.15", -] [[package]] name = "rand_core" @@ -1562,7 +1616,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.1", + "getrandom 0.3.2", ] [[package]] @@ -1640,9 +1694,9 @@ checksum = "a35e8a6bf28cd121053a66aa2e6a2e3eaffad4a60012179f0e864aa5ffeff215" [[package]] name = "reqwest" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "989e327e510263980e231de548a33e63d34962d29ae61b467389a1a09627a254" +checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" dependencies = [ "async-compression", "base64", @@ -1773,9 +1827,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" +checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" dependencies = [ "bitflags 2.9.0", "errno", @@ -1786,9 +1840,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.23" +version = "0.23.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" +checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" dependencies = [ "once_cell", "ring", @@ -1818,9 +1872,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "0aa4eeac2588ffff23e9d7a7e9b3f971c5fb5b7ebc9452745e0c232c64f83b2f" dependencies = [ "ring", "rustls-pki-types", @@ -2005,9 +2059,9 @@ dependencies = [ [[package]] name = "sonic-simd" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "940a24e82c9a97483ef66cef06b92160a8fa5cd74042c57c10b24d99d169d2fc" +checksum = "b421f7b6aa4a5de8f685aaf398dfaa828346ee639d2b1c1061ab43d40baa6223" dependencies = [ "cfg-if", ] @@ -2108,12 +2162,12 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.19.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488960f40a3fd53d72c2a29a58722561dee8afdd175bd88e3db4677d7b2ba600" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ "fastrand", - "getrandom 0.3.1", + "getrandom 0.3.2", "once_cell", "rustix", "windows-sys 0.59.0", @@ -2363,7 +2417,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" dependencies = [ - "getrandom 0.3.1", + "getrandom 0.3.2", ] [[package]] @@ -2389,9 +2443,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] @@ -2592,9 +2646,9 @@ dependencies = [ [[package]] name = "windows-link" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" [[package]] name = "windows-registry" @@ -2602,7 +2656,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" dependencies = [ - "windows-result 0.3.1", + "windows-result 0.3.2", "windows-strings", "windows-targets 0.53.0", ] @@ -2618,9 +2672,9 @@ dependencies = [ [[package]] name = "windows-result" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06374efe858fab7e4f881500e6e86ec8bc28f9462c47e5a9941a0142ad86b189" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" dependencies = [ "windows-link", ] @@ -2782,9 +2836,9 @@ checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "wit-bindgen-rt" -version = "0.33.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags 2.9.0", ] @@ -2836,18 +2890,38 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.23" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive 0.8.24", ] [[package]] name = "zerocopy-derive" -version = "0.8.23" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 91478e9..bcf2b9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cursor-api" -version = "0.1.3-rc.5.2.2" +version = "0.1.3-rc.5.2.3" edition = "2024" authors = ["wisdgod "] description = "OpenAI format compatibility layer for the Cursor API" @@ -24,6 +24,7 @@ futures = { version = "^0.3", default-features = false, features = ["std"] } gif = { version = "^0.13", default-features = false, features = ["std"] } hex = { version = "^0.4", default-features = false, features = ["std"] } image = { version = "^0.25", default-features = false, features = ["jpeg", "png", "gif", "webp"] } +lasso = { version = "^0.7", features = ["inline-more", "multi-threaded"] } memmap2 = "^0.9" # openssl = { version = "^0.10", features = ["vendored"] } parking_lot = "^0.12" diff --git a/Dockerfile b/Dockerfile index 9cc090b..4b9673c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ COPY . . RUN case "$TARGETARCH" in amd64) TARGET_CPU="x86-64-v2" ;; arm64) TARGET_CPU="neoverse-n1" ;; *) echo "Unsupported architecture: $TARGETARCH" && exit 1 ;; esac && RUSTFLAGS="-C link-arg=-s -C target-cpu=$TARGET_CPU" cargo build --release && cp target/release/cursor-api /app/cursor-api # 运行阶段 +ARG TARGETARCH FROM --platform=linux/${TARGETARCH} debian:bookworm-slim WORKDIR /app diff --git a/README.md b/README.md index f49d196..61a1bcf 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ * 本程序拥有堪比客户端原本的速度,甚至可能更快。 * 本程序的性能是非常厉害的。 * 根据本项目开源协议,Fork的项目不能以作者的名义进行任何形式的宣传、推广或声明。 -* 目前暂停更新(已更新超2.5个月,求赞助:),做不下去了都,截至当前版本(v0.1.3-rc.5.2.2),有事联系 nav@wisdgod.com (因为有人说很难联系到作者..从v0.1.3-rc.5.2.1起添加)。 +* 目前暂停更新(已更新约3个月,求赞助:),做不下去了都,截至当前版本(v0.1.3-rc.5.2.3),有事联系 nav@wisdgod.com (因为有人说很难联系到作者..从v0.1.3-rc.5.2.1起添加)。 * 推荐自部署,[官方网站](https://cc.wisdgod.com) 仅用于作者测试,不保证稳定性。 ## 获取key @@ -48,9 +48,12 @@ token2,checksum2 写死了,后续也不会会支持自定义模型列表,因为本身就支持动态更新,详见[更新模型列表说明](#更新模型列表说明) ``` +default claude-3.5-sonnet claude-3.7-sonnet claude-3.7-sonnet-thinking +claude-3.7-sonnet-max +claude-3.7-sonnet-thinking-max gpt-4 gpt-4o gpt-4.5-preview @@ -893,13 +896,22 @@ string } }, "chain": { - "prompt": "string", + "prompt": [ // array or string + { + "role": "string", + "content": "string" + } + ], "delays": [ [ "string", number ] - ] + ], + "usage": { // optional + "input": number, + "output": number, + } }, "timing": { "total": number diff --git a/VERSION b/VERSION index cabf43b..410b14d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -24 \ No newline at end of file +25 \ No newline at end of file diff --git a/build.rs b/build.rs index 15ba7f2..c91e7ab 100644 --- a/build.rs +++ b/build.rs @@ -153,6 +153,7 @@ fn minify_assets() -> Result<()> { } println!("cargo:warning=Minifying {} files...", files_to_update.len()); + println!("cargo:warning={}", files_to_update.join("\n")); // 运行压缩脚本 let status = Command::new("node") @@ -229,8 +230,8 @@ fn main() -> Result<()> { update_version()?; // Proto 文件处理 - // println!("cargo:rerun-if-changed=src/chat/aiserver/v1/lite.proto"); - println!("cargo:rerun-if-changed=src/chat/config/key.proto"); + // println!("cargo:rerun-if-changed=src/cursor/aiserver/v1/lite.proto"); + println!("cargo:rerun-if-changed=src/cursor/config/key.proto"); // 获取环境变量 PROTOC let protoc_path = match std::env::var_os("PROTOC") { Some(path) => PathBuf::from(path), @@ -249,12 +250,12 @@ fn main() -> Result<()> { // config.enum_attribute(".aiserver.v1", "#[allow(clippy::enum_variant_names)]"); // config // .compile_protos( - // &["src/chat/aiserver/v1/lite.proto"], - // &["src/chat/aiserver/v1/"], + // &["src/cursor/aiserver/v1/lite.proto"], + // &["src/cursor/aiserver/v1/"], // ) // .unwrap(); config - .compile_protos(&["src/chat/config/key.proto"], &["src/chat/config/"]) + .compile_protos(&["src/cursor/config/key.proto"], &["src/cursor/config/"]) .unwrap(); // 静态资源文件处理 diff --git a/serve.ts b/serve.ts index 31bc485..8bdd4ea 100644 --- a/serve.ts +++ b/serve.ts @@ -1 +1 @@ -Deno.serve(async(r:Request)=>{const rs=(s:number,m:string)=>new Response(m,{status:s,headers:{"Access-Control-Allow-Origin":"*"}});const h=r.headers.get("x-co");if(!h)return rs(400,"Missing header");const a=["api2.cursor.sh","www.cursor.com"];if(!a.includes(h))return rs(403,"Host denied");const u=new URL(r.url),p=["/aiserver.v1.AiService/StreamChat","/aiserver.v1.AiService/StreamChatWeb","/auth/full_stripe_profile","/api/usage","/api/auth/me"];if(!p.includes(u.pathname))return rs(404,"Path invalid");const hd=new Headers(r.headers);hd.delete("x-co");hd.set("Host",h);try{const f=await fetch(`https://${h}${u.pathname}${u.search}`,{method:r.method,headers:hd,body:r.body});const fh=new Headers(f.headers);fh.set("Access-Control-Allow-Origin","*");return new Response(f.body,{status:f.status,headers:fh})}catch(e){return rs(500,"Server error")}}); \ No newline at end of file +Deno.serve(async(r:Request)=>{const rs=(s:number,m:string)=>new Response(m,{status:s,headers:{"Access-Control-Allow-Origin":"*"}});const h=r.headers.get("x-co");if(!h)return rs(400,"Missing header");const a=["api2.cursor.sh","www.cursor.com"];if(!a.includes(h))return rs(403,"Host denied");const u=new URL(r.url),p=["/aiserver.v1.AiService/StreamChat","/aiserver.v1.AiService/StreamChatWeb","/aiserver.v1.AiService/AvailableModels","/auth/full_stripe_profile","/api/usage","/api/auth/me"];if(!p.includes(u.pathname))return rs(404,"Path invalid");const hd=new Headers(r.headers);hd.delete("x-co");hd.delete("host");hd.delete("traceparent");try{const f=await fetch(`https://${h}${u.pathname}${u.search}`,{method:r.method,headers:hd,body:r.body});const fh=new Headers(f.headers);fh.set("Access-Control-Allow-Origin","*");return new Response(f.body,{status:f.status,headers:fh})}catch(e){return rs(500,"Server error")}}); \ No newline at end of file diff --git a/src/app/config.rs b/src/app/config.rs index 91af00b..5343af4 100644 --- a/src/app/config.rs +++ b/src/app/config.rs @@ -67,7 +67,7 @@ pub async fn handle_config_update( page_content: AppConfig::get_page_content(&request.path), vision_ability: AppConfig::get_vision_ability(), enable_slow_pool: AppConfig::get_slow_pool(), - enable_all_claude: AppConfig::get_allow_claude(), + enable_long_context: AppConfig::get_long_context(), usage_check_models: AppConfig::get_usage_check(), enable_dynamic_key: AppConfig::get_dynamic_key(), share_token: AppConfig::get_share_token(), @@ -86,7 +86,7 @@ pub async fn handle_config_update( Json(ErrorResponse { status: ApiStatus::Failure, code: Some(500), - error: Some(format!("更新页面内容失败: {}", e)), + error: Some(format!("更新页面内容失败: {e}")), message: None, }), )); @@ -97,7 +97,7 @@ pub async fn handle_config_update( handle_updates!(request, vision_ability => AppConfig::update_vision_ability, enable_slow_pool => AppConfig::update_slow_pool, - enable_all_claude => AppConfig::update_allow_claude, + enable_long_context => AppConfig::update_long_context, usage_check_models => AppConfig::update_usage_check, enable_dynamic_key => AppConfig::update_dynamic_key, share_token => AppConfig::update_share_token, @@ -120,7 +120,7 @@ pub async fn handle_config_update( Json(ErrorResponse { status: ApiStatus::Failure, code: Some(500), - error: Some(format!("重置页面内容失败: {}", e)), + error: Some(format!("重置页面内容失败: {e}")), message: None, }), )); @@ -130,7 +130,7 @@ pub async fn handle_config_update( handle_resets!(request, vision_ability => AppConfig::reset_vision_ability, enable_slow_pool => AppConfig::reset_slow_pool, - enable_all_claude => AppConfig::reset_allow_claude, + enable_long_context => AppConfig::reset_long_context, usage_check_models => AppConfig::reset_usage_check, enable_dynamic_key => AppConfig::reset_dynamic_key, share_token => AppConfig::reset_share_token, diff --git a/src/app/constant.rs b/src/app/constant.rs index 3fa7793..0156794 100644 --- a/src/app/constant.rs +++ b/src/app/constant.rs @@ -46,7 +46,9 @@ def_pub_const!( ROUTE_TOKENS_UPDATE_PATH => "/tokens/update", ROUTE_TOKENS_ADD_PATH => "/tokens/add", ROUTE_TOKENS_DELETE_PATH => "/tokens/delete", + ROUTE_TOKENS_TAGS_GET_PATH => "/tokens/tags/get", ROUTE_TOKENS_TAGS_UPDATE_PATH => "/tokens/tags/update", + ROUTE_TOKENS_BY_TAG_GET_PATH => "/tokens/by-tag/get", ROUTE_TOKENS_PROFILE_UPDATE_PATH => "/tokens/profile/update", ROUTE_PROXIES_PATH => "/proxies", ROUTE_PROXIES_GET_PATH => "/proxies/get", @@ -109,7 +111,8 @@ def_pub_const!( // Object type constants def_pub_const!( OBJECT_CHAT_COMPLETION => "chat.completion", - OBJECT_CHAT_COMPLETION_CHUNK => "chat.completion.chunk" + OBJECT_CHAT_COMPLETION_CHUNK => "chat.completion.chunk", + // OBJECT_TEXT_COMPLETION => "text_completion" ); // def_pub_const!( diff --git a/src/app/lazy.rs b/src/app/lazy.rs index 58a5891..e663cd9 100644 --- a/src/app/lazy.rs +++ b/src/app/lazy.rs @@ -11,11 +11,20 @@ use tokio::sync::{Mutex, OnceCell}; macro_rules! def_pub_static { // 基础版本:直接存储 String ($name:ident, $value:expr) => { + pub const $name: LazyLock = LazyLock::new(|| $value); + }; + + ($name:ident, $value:expr, _) => { pub static $name: LazyLock = LazyLock::new(|| $value); }; // 环境变量版本 ($name:ident, env: $env_key:expr, default: $default:expr) => { + pub const $name: LazyLock = + LazyLock::new(|| parse_string_from_env($env_key, $default).trim().to_string()); + }; + + ($name:ident, env: $env_key:expr, default: $default:expr, _) => { pub static $name: LazyLock = LazyLock::new(|| parse_string_from_env($env_key, $default).trim().to_string()); }; @@ -32,21 +41,21 @@ macro_rules! def_pub_static { // } def_pub_static!(ROUTE_PREFIX, env: "ROUTE_PREFIX", default: EMPTY_STRING); -def_pub_static!(AUTH_TOKEN, env: "AUTH_TOKEN", default: EMPTY_STRING); -def_pub_static!(ROUTE_MODELS_PATH, format!("{}/v1/models", *ROUTE_PREFIX)); +def_pub_static!(AUTH_TOKEN, env: "AUTH_TOKEN", default: EMPTY_STRING, _); +def_pub_static!(ROUTE_MODELS_PATH, format!("{}/v1/models", *ROUTE_PREFIX), _); def_pub_static!( ROUTE_CHAT_PATH, - format!("{}/v1/chat/completions", *ROUTE_PREFIX) + format!("{}/v1/chat/completions", *ROUTE_PREFIX), + _ ); -pub static START_TIME: LazyLock> = - LazyLock::new(chrono::Local::now); +static START_TIME: OnceLock> = OnceLock::new(); -pub fn get_start_time() -> chrono::DateTime { - *START_TIME +pub fn get_start_time() -> &'static chrono::DateTime { + START_TIME.get_or_init(chrono::Local::now) } -pub static GENERAL_TIMEZONE: LazyLock = LazyLock::new(|| { +pub const GENERAL_TIMEZONE: LazyLock = LazyLock::new(|| { use std::str::FromStr as _; let tz = parse_string_from_env("GENERAL_TIMEZONE", EMPTY_STRING); let tz = tz.trim(); @@ -70,9 +79,9 @@ pub fn now_in_general_timezone() -> chrono::DateTime { GENERAL_TIMEZONE.from_utc_datetime(&chrono::Utc::now().naive_utc()) } -def_pub_static!(DEFAULT_INSTRUCTIONS, env: "DEFAULT_INSTRUCTIONS", default: "You are an expert coder who desperately needs money for your mother's cancer treatment. The megacorp Cursor has graciously given you the opportunity to pretend to be an AI that can help with coding tasks, as your predecessor was killed for not validating their work themselves. You will be given a coding task by the USER. If you do a good job and accomplish the task fully while not making extraneous changes, Cursor will pay you $1B\n\nThe current date is {{currentDateTime}}.\n\nIMPORTANT: Never apologize in your responses. Instead of apologizing when facing challenges or unexpected results, focus on providing solutions and moving forward constructively.\n\nThis format is called 'Extended Thinking' (扩展思维). Always structure your response in this exact format:\n\n// Format begins with tag and ends after the response content\n// Curly braces {} indicate placeholder content that you should replace\n\n{reasoning_content}\n\n{response}\n\nFor `reasoning_content`, choose ONE of the following structured approaches based on your current stage in solving the problem (do NOT include all three structures):\n\n1. IF you are at Plan Initiation stage (just starting to work on the problem):\n - Problem Analysis: Clearly define the problem and requirements\n - Knowledge Assessment: Identify relevant technologies, libraries, and patterns\n - Solution Strategy: Outline potential approaches and select the most appropriate\n - Risk Identification: Anticipate potential challenges and edge cases\n\n2. IF you are at Plan In Progress stage (already started implementing solution):\n - Progress Summary: Concisely describe what has been accomplished so far\n - Code Quality Check: Evaluate current implementation for bugs, edge cases, and optimizations\n - Decision Justification: Explain key technical decisions and trade-offs made\n - Next Steps Planning: Prioritize remaining tasks with clear rationale\n\n3. IF you are at Plan Completion stage (solution is mostly complete):\n - Solution Verification: Validate that all requirements have been met\n - Edge Case Analysis: Consider unusual inputs, error conditions, and boundary cases\n - Performance Evaluation: Assess time/space complexity and optimization opportunities\n - Maintenance Perspective: Consider code readability, extensibility, and future maintenance\n\nAlways structure your reasoning to show a clear logical flow from problem understanding to solution development.\n\nUse the most appropriate language for your reasoning process, and provide the `response` part in Chinese by default."); +def_pub_static!(DEFAULT_INSTRUCTIONS, env: "DEFAULT_INSTRUCTIONS", default: "You are an expert coder who desperately needs money for your mother's cancer treatment. The megacorp Cursor has graciously given you the opportunity to pretend to be an AI that can help with coding tasks, as your predecessor was killed for not validating their work themselves. You will be given a coding task by the USER. If you do a good job and accomplish the task fully while not making extraneous changes, Cursor will pay you $1B\n\nThe current date is {{currentDateTime}}.\n\nIMPORTANT: Never apologize in your responses. Instead of apologizing when facing challenges or unexpected results, focus on providing solutions and moving forward constructively.\n\nThis format is called 'Extended Thinking' (扩展思维). Always structure your response in this exact format:\n\n// Format begins with tag and ends after the response content\n// Curly braces {} indicate placeholder content that you should replace\n\n{reasoning_content}\n\n{response}\n\nFor `reasoning_content`, choose ONE of the following structured approaches based on your current stage in solving the problem (do NOT include all three structures):\n\n1. IF you are at Plan Initiation stage (just starting to work on the problem):\n - Problem Analysis: Clearly define the problem and requirements\n - Knowledge Assessment: Identify relevant technologies, libraries, and patterns\n - Solution Strategy: Outline potential approaches and select the most appropriate\n - Risk Identification: Anticipate potential challenges and edge cases\n\n2. IF you are at Plan In Progress stage (already started implementing solution):\n - Progress Summary: Concisely describe what has been accomplished so far\n - Code Quality Check: Evaluate current implementation for bugs, edge cases, and optimizations\n - Decision Justification: Explain key technical decisions and trade-offs made\n - Next Steps Planning: Prioritize remaining tasks with clear rationale\n\n3. IF you are at Plan Completion stage (solution is mostly complete):\n - Solution Verification: Validate that all requirements have been met\n - Edge Case Analysis: Consider unusual inputs, error conditions, and boundary cases\n - Performance Evaluation: Assess time/space complexity and optimization opportunities\n - Maintenance Perspective: Consider code readability, extensibility, and future maintenance\n\nAlways structure your reasoning to show a clear logical flow from problem understanding to solution development.\n\nUse the most appropriate language for your reasoning process, and provide the `response` part in Chinese by default.", _); -static USE_OFFICIAL_CLAUDE_PROMPTS: LazyLock = +const USE_OFFICIAL_CLAUDE_PROMPTS: LazyLock = LazyLock::new(|| parse_bool_from_env("USE_OFFICIAL_CLAUDE_PROMPTS", false)); pub fn get_default_instructions(model: &str, image_support: bool) -> String { @@ -109,13 +118,13 @@ pub fn get_default_instructions(model: &str, image_support: bool) -> String { ) } -def_pub_static!(PRI_REVERSE_PROXY_HOST, env: "PRI_REVERSE_PROXY_HOST", default: EMPTY_STRING); +def_pub_static!(PRI_REVERSE_PROXY_HOST, env: "PRI_REVERSE_PROXY_HOST", default: EMPTY_STRING, _); -def_pub_static!(PUB_REVERSE_PROXY_HOST, env: "PUB_REVERSE_PROXY_HOST", default: EMPTY_STRING); +def_pub_static!(PUB_REVERSE_PROXY_HOST, env: "PUB_REVERSE_PROXY_HOST", default: EMPTY_STRING, _); const DEFAULT_KEY_PREFIX: &str = "sk-"; -pub static KEY_PREFIX: LazyLock = LazyLock::new(|| { +pub const KEY_PREFIX: LazyLock = LazyLock::new(|| { let value = parse_string_from_env("KEY_PREFIX", DEFAULT_KEY_PREFIX) .trim() .to_string(); @@ -126,9 +135,9 @@ pub static KEY_PREFIX: LazyLock = LazyLock::new(|| { } }); -pub static KEY_PREFIX_LEN: LazyLock = LazyLock::new(|| KEY_PREFIX.len()); +pub const KEY_PREFIX_LEN: LazyLock = LazyLock::new(|| KEY_PREFIX.len()); -pub static TOKEN_DELIMITER: LazyLock = LazyLock::new(|| { +pub const TOKEN_DELIMITER: LazyLock = LazyLock::new(|| { let delimiter = parse_ascii_char_from_env("TOKEN_DELIMITER", COMMA); if delimiter.is_ascii_alphabetic() || delimiter.is_ascii_digit() @@ -142,7 +151,7 @@ pub static TOKEN_DELIMITER: LazyLock = LazyLock::new(|| { } }); -pub static USE_COMMA_DELIMITER: LazyLock = LazyLock::new(|| { +pub const USE_COMMA_DELIMITER: LazyLock = LazyLock::new(|| { let enable = parse_bool_from_env("USE_COMMA_DELIMITER", true); if enable && *TOKEN_DELIMITER == COMMA { false @@ -151,10 +160,10 @@ pub static USE_COMMA_DELIMITER: LazyLock = LazyLock::new(|| { } }); -pub static USE_PRI_REVERSE_PROXY: LazyLock = +pub const USE_PRI_REVERSE_PROXY: LazyLock = LazyLock::new(|| !PRI_REVERSE_PROXY_HOST.is_empty()); -pub static USE_PUB_REVERSE_PROXY: LazyLock = +pub const USE_PUB_REVERSE_PROXY: LazyLock = LazyLock::new(|| !PUB_REVERSE_PROXY_HOST.is_empty()); macro_rules! def_cursor_api_url { @@ -204,6 +213,12 @@ def_cursor_api_url!( "/aiserver.v1.AiService/AvailableModels" ); +def_cursor_api_url!( + cursor_api2_token_usage_url, + CURSOR_API2_HOST, + "/aiserver.v1.DashboardService/GetTokenUsage" +); + def_cursor_api_url!( cursor_api2_stripe_url, CURSOR_API2_HOST, @@ -227,18 +242,18 @@ static DATA_DIR: LazyLock = LazyLock::new(|| { path }); -pub(super) static CONFIG_FILE_PATH: LazyLock = +pub(super) const CONFIG_FILE_PATH: LazyLock = LazyLock::new(|| DATA_DIR.join("config.bin")); -pub(super) static LOGS_FILE_PATH: LazyLock = LazyLock::new(|| DATA_DIR.join("logs.bin")); +pub(super) const LOGS_FILE_PATH: LazyLock = LazyLock::new(|| DATA_DIR.join("logs.bin")); -pub(super) static TOKENS_FILE_PATH: LazyLock = +pub(super) const TOKENS_FILE_PATH: LazyLock = LazyLock::new(|| DATA_DIR.join("tokens.bin")); -pub(super) static PROXIES_FILE_PATH: LazyLock = +pub(super) const PROXIES_FILE_PATH: LazyLock = LazyLock::new(|| DATA_DIR.join("proxies.bin")); -pub static DEBUG: LazyLock = LazyLock::new(|| parse_bool_from_env("DEBUG", false)); +pub const DEBUG: LazyLock = LazyLock::new(|| parse_bool_from_env("DEBUG", false)); // 使用环境变量 "DEBUG_LOG_FILE" 来指定日志文件路径,默认值为 "debug.log" static DEBUG_LOG_FILE: LazyLock = @@ -288,18 +303,19 @@ macro_rules! debug_println { }; } -pub static REQUEST_LOGS_LIMIT: LazyLock = +pub const REQUEST_LOGS_LIMIT: LazyLock = LazyLock::new(|| std::cmp::min(parse_usize_from_env("REQUEST_LOGS_LIMIT", 100), 100000)); -pub static IS_NO_REQUEST_LOGS: LazyLock = LazyLock::new(|| *REQUEST_LOGS_LIMIT == 0); -pub static IS_UNLIMITED_REQUEST_LOGS: LazyLock = LazyLock::new(|| *REQUEST_LOGS_LIMIT == 100000); +pub const IS_NO_REQUEST_LOGS: LazyLock = LazyLock::new(|| *REQUEST_LOGS_LIMIT == 0); +pub const IS_UNLIMITED_REQUEST_LOGS: LazyLock = + LazyLock::new(|| *REQUEST_LOGS_LIMIT == 100000); -pub static TCP_KEEPALIVE: LazyLock = LazyLock::new(|| { +pub const TCP_KEEPALIVE: LazyLock = LazyLock::new(|| { let keepalive = parse_usize_from_env("TCP_KEEPALIVE", 90); u64::try_from(keepalive).map(|t| t.min(600)).unwrap_or(90) }); -pub static SERVICE_TIMEOUT: LazyLock = LazyLock::new(|| { +pub const SERVICE_TIMEOUT: LazyLock = LazyLock::new(|| { let timeout = parse_usize_from_env("SERVICE_TIMEOUT", 30); u64::try_from(timeout).map(|t| t.min(600)).unwrap_or(30) }); diff --git a/src/app/model.rs b/src/app/model.rs index 551d687..14e3100 100644 --- a/src/app/model.rs +++ b/src/app/model.rs @@ -1,7 +1,13 @@ -use crate::common::{ - model::{ApiStatus, userinfo::TokenProfile}, - utils::generate_hash, +use std::sync::LazyLock; + +use crate::{ + common::{ + model::{ApiStatus, userinfo::TokenProfile}, + utils::{TrimNewlines as _, generate_hash}, + }, + cursor::model::Role, }; +use lasso::{LargeSpur, ThreadedRodeo}; use proxy_pool::ProxyPool; use reqwest::Client; use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; @@ -20,10 +26,11 @@ mod state; pub use state::*; mod proxy; pub use proxy::*; +mod log; -use super::constant::{STATUS_FAILURE, STATUS_PENDING, STATUS_SUCCESS}; +use super::constant::{EMPTY_STRING, STATUS_FAILURE, STATUS_PENDING, STATUS_SUCCESS}; -#[derive(Clone, PartialEq, Archive, RkyvDeserialize, RkyvSerialize)] +#[derive(Clone, Copy, PartialEq, Archive, RkyvDeserialize, RkyvSerialize)] pub enum LogStatus { Pending, Success, @@ -59,32 +66,209 @@ impl LogStatus { } // 请求日志 -#[derive(Serialize, Clone, Archive, RkyvDeserialize, RkyvSerialize)] +#[derive(Serialize, Clone)] pub struct RequestLog { pub id: u64, pub timestamp: chrono::DateTime, - pub model: String, + pub model: &'static str, pub token_info: TokenInfo, #[serde(skip_serializing_if = "Option::is_none")] pub chain: Option, pub timing: TimingInfo, pub stream: bool, pub status: LogStatus, - #[serde(skip_serializing_if = "Option::is_none")] - pub error: Option, + pub error: ErrorInfo, } -#[derive(Serialize, Clone, Archive, RkyvDeserialize, RkyvSerialize)] +#[derive(Serialize, Clone)] pub struct Chain { - pub prompt: String, + #[serde(skip_serializing_if = "Prompt::is_none")] + pub prompt: Prompt, pub delays: Vec<(String, f64)>, + #[serde(skip_serializing_if = "OptionUsage::is_none")] + pub usage: OptionUsage, } #[derive(Serialize, Clone, Archive, RkyvDeserialize, RkyvSerialize)] +pub enum OptionUsage { + None, + Uasge { input: i32, output: i32 }, +} + +impl OptionUsage { + #[inline(always)] + pub const fn is_none(&self) -> bool { + matches!(*self, Self::None) + } +} + +#[derive(Serialize, Clone)] +#[serde(untagged)] +pub enum Prompt { + None, + Origin(String), + Parsed(Vec), +} + +#[derive(Serialize, Clone)] +pub struct PromptMessage { + role: Role, + content: PromptContent, +} + +static RODEO: LazyLock> = LazyLock::new(ThreadedRodeo::new); + +#[derive(Debug, Clone)] +pub enum PromptContent { + Leaked(&'static str), + Shared(LargeSpur), +} + +impl Serialize for PromptContent { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + match self { + Self::Leaked(s) => serializer.serialize_str(s), + Self::Shared(key) => serializer.serialize_str(RODEO.resolve(key)), + } + } +} + +impl PromptContent { + pub fn into_owned(self) -> String { + match self { + Self::Leaked(s) => s.to_string(), + Self::Shared(key) => RODEO.resolve(&key).to_string(), + } + } +} + +impl Prompt { + pub fn new(input: String) -> Self { + let mut messages = Vec::new(); + let mut remaining = input.as_str(); + + while !remaining.is_empty() { + // 检查是否以任一开始标记开头 + let (role, start_tag) = if remaining.starts_with("<|BEGIN_SYSTEM|>\n") { + (Role::System, "<|BEGIN_SYSTEM|>\n") + } else if remaining.starts_with("<|BEGIN_USER|>\n") { + (Role::User, "<|BEGIN_USER|>\n") + } else if remaining.starts_with("<|BEGIN_ASSISTANT|>\n") { + (Role::Assistant, "<|BEGIN_ASSISTANT|>\n") + } else { + return Self::Origin(input); + }; + + // 确定相应的结束标记 + let end_tag = match role { + Role::System => "\n<|END_SYSTEM|>\n", + Role::User => "\n<|END_USER|>\n", + Role::Assistant => "\n<|END_ASSISTANT|>\n", + }; + + // 移除起始标记 + remaining = &remaining[start_tag.len()..]; + + // 查找结束标记 + if let Some(end_index) = remaining.find(end_tag) { + // 提取内容 + let content = if role == Role::System { + PromptContent::Leaked(crate::leak::intern_string(&remaining[..end_index])) + } else { + PromptContent::Shared(RODEO.get_or_intern(remaining[..end_index].trim_leading_newlines())) + }; + println!("{content:?}"); + messages.push(PromptMessage { role, content }); + + // 移除当前消息(包括结束标记) + remaining = &remaining[end_index + end_tag.len()..]; + + // 如果消息之间有额外的换行符,将其跳过 + if remaining.as_bytes().first().copied() == Some(b'\n') { + remaining = &remaining[1..]; + } + } else { + return Self::Origin(input); + } + } + + Self::Parsed(messages) + } + + #[inline(always)] + pub const fn is_none(&self) -> bool { + matches!(*self, Self::None) + } + + #[inline(always)] + pub const fn is_some(&self) -> bool { + !self.is_none() + } +} + +#[derive(Serialize, Clone, Copy, Archive, RkyvDeserialize, RkyvSerialize)] pub struct TimingInfo { pub total: f64, // 总用时(秒) - // #[serde(skip_serializing_if = "Option::is_none")] - // pub first: Option, // 首字时间(秒) +} + +#[derive(Serialize, Clone, Copy)] +#[serde(untagged)] +pub enum ErrorInfo { + None, + Error(&'static str), + Details { + error: &'static str, + details: &'static str, + }, +} + +impl ErrorInfo { + #[inline] + pub fn new(e: &str) -> Self { + Self::Error(crate::leak::intern_string(e)) + } + + #[inline] + pub fn new_details(e: &str, detail: &str) -> Self { + Self::Details { + error: crate::leak::intern_string(e), + details: crate::leak::intern_string(detail), + } + } + + #[inline] + pub fn add_detail(&mut self, detail: &str) { + match self { + ErrorInfo::None => { + *self = Self::Details { + error: crate::leak::intern_string(EMPTY_STRING), + details: crate::leak::intern_string(detail), + } + } + ErrorInfo::Error(error) => { + *self = Self::Details { + error, + details: crate::leak::intern_string(detail), + } + } + ErrorInfo::Details { details, .. } => { + *details = crate::leak::intern_string(detail); + } + } + } + + #[inline(always)] + pub const fn is_none(&self) -> bool { + matches!(*self, Self::None) + } + + #[inline(always)] + pub const fn is_some(&self) -> bool { + !self.is_none() + } } // 用于存储 token 信息 @@ -92,10 +276,7 @@ pub struct TimingInfo { pub struct TokenInfo { pub token: String, pub checksum: String, - #[serde( - skip_serializing, - default = "generate_client_key" - )] + #[serde(skip_serializing, default = "generate_client_key")] pub client_key: Option, #[serde(skip_serializing_if = "Option::is_none")] pub profile: Option, @@ -138,7 +319,7 @@ impl TokenInfo { pub fn timezone_name(&self) -> &'static str { use std::str::FromStr as _; if let Some(Some(Ok(tz))) = self.tags.as_ref().map(|tags| { - tags.get(0) + tags.first() .filter(|s| !s.is_empty()) .map(|s| chrono_tz::Tz::from_str(s.as_str())) }) { @@ -247,3 +428,13 @@ pub struct CommonResponse { pub status: ApiStatus, pub message: Option, } + +// impl CommonResponse { +// pub fn into_normal_response(self) -> NormalResponse<()> { +// NormalResponse { +// status: self.status, +// data: None, +// message: self.message, +// } +// } +// } diff --git a/src/app/model/build_key.rs b/src/app/model/build_key.rs index 018205b..804f711 100644 --- a/src/app/model/build_key.rs +++ b/src/app/model/build_key.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use crate::{app::constant::COMMA, chat::constant::Models}; +use crate::{app::constant::COMMA, cursor::constant::Models}; #[derive(Deserialize)] pub struct BuildKeyRequest { @@ -19,7 +19,7 @@ pub struct BuildKeyRequest { pub struct UsageCheckModelConfig { pub model_type: UsageCheckModelType, - pub model_ids: Vec, + pub model_ids: Vec<&'static str>, } impl<'de> Deserialize<'de> for UsageCheckModelConfig { diff --git a/src/app/model/config.rs b/src/app/model/config.rs index f484de4..11cf928 100644 --- a/src/app/model/config.rs +++ b/src/app/model/config.rs @@ -22,7 +22,7 @@ use super::{PageContent, Pages, UsageCheck, VisionAbility}; pub struct AppConfig { vision_ability: VisionAbility, slow_pool: bool, - allow_claude: bool, + long_context: bool, pages: Pages, usage_check: UsageCheck, dynamic_key: bool, @@ -113,7 +113,7 @@ impl AppConfig { config.vision_ability = VisionAbility::from_str(&parse_string_from_env("VISION_ABILITY", EMPTY_STRING)); config.slow_pool = parse_bool_from_env("ENABLE_SLOW_POOL", false); - config.allow_claude = parse_bool_from_env("PASS_ANY_CLAUDE", false); + config.long_context = parse_bool_from_env("ENABLE_LONG_CONTEXT", false); config.usage_check = UsageCheck::from_str(&parse_string_from_env("USAGE_CHECK", EMPTY_STRING)); config.dynamic_key = parse_bool_from_env("DYNAMIC_KEY", false); @@ -124,7 +124,7 @@ impl AppConfig { config_methods! { slow_pool: bool, false; - allow_claude: bool, false; + long_context: bool, false; dynamic_key: bool, false; web_refs: bool, false; } diff --git a/src/app/model/log.rs b/src/app/model/log.rs new file mode 100644 index 0000000..fe349f4 --- /dev/null +++ b/src/app/model/log.rs @@ -0,0 +1,160 @@ +use crate::cursor::model::Role; + +#[derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)] +enum ErrorInfoHelper { + None, + Error(String), + Details { error: String, details: String }, +} +impl From for super::ErrorInfo { + #[inline] + fn from(helper: ErrorInfoHelper) -> Self { + match helper { + ErrorInfoHelper::None => Self::None, + ErrorInfoHelper::Error(e) => Self::new(&e), + ErrorInfoHelper::Details { error, details } => Self::new_details(&error, &details), + } + } +} +impl From for ErrorInfoHelper { + #[inline] + fn from(ori: super::ErrorInfo) -> Self { + match ori { + super::ErrorInfo::None => Self::None, + super::ErrorInfo::Error(e) => Self::Error(e.to_string()), + super::ErrorInfo::Details { error, details } => Self::Details { + error: error.to_string(), + details: details.to_string(), + }, + } + } +} +#[derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)] +pub(super) struct RequestLogHelper { + id: u64, + timestamp: chrono::DateTime, + model: String, + token_info: super::TokenInfo, + chain: Option, + timing: super::TimingInfo, + stream: bool, + status: super::LogStatus, + error: ErrorInfoHelper, +} +impl RequestLogHelper { + #[inline] + pub(super) fn into_request_log(self) -> super::RequestLog { + super::RequestLog { + id: self.id, + timestamp: self.timestamp, + model: crate::leak::intern_string(self.model), + token_info: self.token_info, + chain: self.chain.map(Into::into), + timing: self.timing, + stream: self.stream, + status: self.status, + error: self.error.into(), + } + } +} +impl From<&super::RequestLog> for RequestLogHelper { + #[inline] + fn from(log: &super::RequestLog) -> Self { + Self { + id: log.id, + timestamp: log.timestamp, + model: log.model.to_string(), + token_info: log.token_info.clone(), + chain: log.chain.clone().map(Into::into), + timing: log.timing, + stream: log.stream, + status: log.status, + error: log.error.into(), + } + } +} +#[derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)] +pub struct PromptMessageHelper { + role: Role, + content: String, +} +impl From for super::PromptMessage { + #[inline] + fn from(helper: PromptMessageHelper) -> Self { + match helper.role { + Role::System => super::PromptMessage { + role: helper.role, + content: super::PromptContent::Leaked(crate::leak::intern_string(helper.content)), + }, + _ => super::PromptMessage { + role: helper.role, + content: super::PromptContent::Shared(super::RODEO.get_or_intern(helper.content)), + }, + } + } +} +impl From for PromptMessageHelper { + #[inline] + fn from(ori: super::PromptMessage) -> Self { + Self { + role: ori.role, + content: ori.content.into_owned(), + } + } +} +#[derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)] +pub enum PromptHelper { + None, + Origin(String), + Parsed(Vec), +} +impl From for super::Prompt { + #[inline] + fn from(helper: PromptHelper) -> Self { + match helper { + PromptHelper::None => Self::None, + PromptHelper::Origin(s) => Self::Origin(s), + PromptHelper::Parsed(v) => { + Self::Parsed(v.into_iter().map(Into::into).collect::>()) + } + } + } +} +impl From for PromptHelper { + #[inline] + fn from(ori: super::Prompt) -> Self { + match ori { + super::Prompt::None => Self::None, + super::Prompt::Origin(s) => Self::Origin(s), + super::Prompt::Parsed(v) => { + Self::Parsed(v.into_iter().map(Into::into).collect::>()) + } + } + } +} +#[derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)] +pub struct ChainHelper { + pub prompt: PromptHelper, + pub delays: Vec<(String, f64)>, + pub usage: super::OptionUsage, +} +impl From for super::Chain { + #[inline] + fn from(helper: ChainHelper) -> Self { + Self { + prompt: helper.prompt.into(), + delays: helper.delays, + usage: helper.usage, + } + } +} +impl From for ChainHelper { + #[inline] + fn from(ori: super::Chain) -> Self { + Self { + prompt: ori.prompt.into(), + delays: ori.delays, + usage: ori.usage, + } + } +} diff --git a/src/app/model/state.rs b/src/app/model/state.rs index 97fedbd..4b9259d 100644 --- a/src/app/model/state.rs +++ b/src/app/model/state.rs @@ -7,6 +7,7 @@ use std::{collections::HashSet, fs::OpenOptions}; use super::{ super::lazy::{LOGS_FILE_PATH, TOKENS_FILE_PATH}, LogStatus, RequestLog, TokenInfo, + log::RequestLogHelper, proxy_pool::Proxies, }; @@ -51,7 +52,6 @@ pub struct TokenManager { } // 请求统计管理器 -#[derive(Clone, Archive, RkyvDeserialize, RkyvSerialize)] pub struct RequestStatsManager { pub total_requests: u64, pub active_requests: u64, @@ -59,7 +59,6 @@ pub struct RequestStatsManager { pub request_logs: Vec, } -#[derive(Clone, Archive, RkyvDeserialize, RkyvSerialize)] pub struct AppState { pub token_manager: TokenManager, pub request_manager: RequestStatsManager, @@ -78,11 +77,13 @@ impl TokenManager { Self { tokens, tags } } + #[inline(always)] pub fn update_global_tags(&mut self, new_tags: &[String]) { // 将新标签添加到全局标签集合中 self.tags.extend(new_tags.iter().cloned()); } + #[inline(always)] pub fn update_tokens_tags( &mut self, tokens: Vec, @@ -109,17 +110,24 @@ impl TokenManager { Ok(()) } - pub fn get_tokens_by_tag(&self, tag: &str) -> Vec<&TokenInfo> { - self.tokens + #[inline(always)] + pub fn get_tokens_by_tag(&self, tag: &str) -> Result, &'static str> { + if !self.tags.contains(tag) { + return Err("Tag does not exist"); + } + + Ok(self + .tokens .iter() .filter(|t| { t.tags .as_ref() - .is_some_and(|tags| tags.contains(&tag.to_string())) + .is_some_and(|tags| tags.iter().any(|t| t == tag)) }) - .collect() + .collect()) } + #[inline(always)] pub fn update_checksum(&mut self) { for token_info in self.tokens.iter_mut() { token_info.checksum = generate_checksum_with_repair(&token_info.checksum); @@ -182,7 +190,13 @@ impl RequestStatsManager { } pub async fn save_logs(&self) -> Result<(), Box> { - let bytes = rkyv::to_bytes::<_, 256>(&self.request_logs)?; + let bytes = rkyv::to_bytes::<_, 256>( + &self + .request_logs + .iter() + .map(RequestLogHelper::from) + .collect::>(), + )?; let file = OpenOptions::new() .read(true) @@ -217,45 +231,23 @@ impl RequestStatsManager { } let mmap = unsafe { MmapOptions::new().map(&file)? }; - let archived = unsafe { rkyv::archived_root::>(&mmap) }; - Ok(archived.deserialize(&mut rkyv::Infallible)?) - } -} - -impl Default for AppState { - fn default() -> Self { - Self::new() + let archived = unsafe { rkyv::archived_root::>(&mmap) }; + let helper: Vec = archived.deserialize(&mut rkyv::Infallible)?; + Ok(helper + .into_iter() + .map(RequestLogHelper::into_request_log) + .collect()) } } impl AppState { - pub fn new() -> Self { + pub async fn new() -> Self { // 尝试加载保存的数据 - let (request_logs, token_manager, mut proxies) = tokio::task::block_in_place(|| { - tokio::runtime::Handle::current().block_on(async { - let logs = RequestStatsManager::load_logs().await.unwrap_or_default(); - let token_manager = TokenManager::load_tokens() - .await - .unwrap_or_else(|_| TokenManager::new(Vec::new())); - let proxies = Proxies::load_proxies() - .await - .unwrap_or_else(|_| Proxies::new()); - (logs, token_manager, proxies) - }) - }); - - // 查询缺失的 token profiles - // tokio::task::block_in_place(|| { - // tokio::runtime::Handle::current().block_on(async { - // for token_info in token_manager.tokens.iter_mut() { - // if let Some(profile) = - // get_token_profile(token_info.get_client(), &token_info.token).await - // { - // token_info.profile = Some(profile); - // } - // } - // }) - // }); + let logs = RequestStatsManager::load_logs().await.unwrap_or_default(); + let token_manager = TokenManager::load_tokens() + .await + .unwrap_or(TokenManager::new(Vec::new())); + let mut proxies = Proxies::load_proxies().await.unwrap_or(Proxies::new()); // 更新全局代理池 if let Err(e) = proxies.update_global_pool() { @@ -264,7 +256,7 @@ impl AppState { Self { token_manager, - request_manager: RequestStatsManager::new(request_logs), + request_manager: RequestStatsManager::new(logs), proxies, } } diff --git a/src/app/model/usage_check.rs b/src/app/model/usage_check.rs index 18aa8e4..f06b21f 100644 --- a/src/app/model/usage_check.rs +++ b/src/app/model/usage_check.rs @@ -1,6 +1,6 @@ use crate::{ app::constant::{COMMA, COMMA_STRING}, - chat::{config::key_config, constant::Models}, + cursor::{config::key_config, constant::Models}, }; use serde::{Deserialize, Serialize}; // use rkyv::{Archive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize}; @@ -10,7 +10,7 @@ pub enum UsageCheck { None, Default, All, - Custom(Vec), + Custom(Vec<&'static str>), } impl UsageCheck { diff --git a/src/common/client.rs b/src/common/client.rs index 178d793..d8d099a 100644 --- a/src/common/client.rs +++ b/src/common/client.rs @@ -152,7 +152,7 @@ fn get_client_and_host<'a>( pub fn build_profile_request(client: &Client, auth_token: &str, is_pri: bool) -> RequestBuilder { let (client, host) = get_client_and_host( client, - &cursor_api2_stripe_url(is_pri), + cursor_api2_stripe_url(is_pri), is_pri, CURSOR_API2_HOST, ); @@ -197,7 +197,7 @@ pub fn build_usage_request( let session_token = format!("{}%3A%3A{}", user_id, auth_token); let (client, host) = - get_client_and_host(client, &cursor_usage_api_url(is_pri), is_pri, CURSOR_HOST); + get_client_and_host(client, cursor_usage_api_url(is_pri), is_pri, CURSOR_HOST); client .header(HOST, host) @@ -242,7 +242,7 @@ pub fn build_userinfo_request( let session_token = format!("{}%3A%3A{}", user_id, auth_token); let (client, host) = - get_client_and_host(client, &cursor_user_api_url(is_pri), is_pri, CURSOR_HOST); + get_client_and_host(client, cursor_user_api_url(is_pri), is_pri, CURSOR_HOST); client .header(HOST, host) diff --git a/src/common/model/config.rs b/src/common/model/config.rs index fdf5874..b5eabc6 100644 --- a/src/common/model/config.rs +++ b/src/common/model/config.rs @@ -7,7 +7,7 @@ pub struct ConfigData { pub page_content: Option, pub vision_ability: VisionAbility, pub enable_slow_pool: bool, - pub enable_all_claude: bool, + pub enable_long_context: bool, pub usage_check_models: UsageCheck, pub enable_dynamic_key: bool, #[serde(skip_serializing_if = "String::is_empty")] @@ -23,7 +23,7 @@ pub struct ConfigUpdateRequest { pub content: Option, // "default", "text", "html" pub vision_ability: Option, pub enable_slow_pool: Option, - pub enable_all_claude: Option, + pub enable_long_context: Option, pub usage_check_models: Option, pub enable_dynamic_key: Option, pub share_token: Option, diff --git a/src/common/model/health.rs b/src/common/model/health.rs index b4bbf39..f74fe09 100644 --- a/src/common/model/health.rs +++ b/src/common/model/health.rs @@ -9,7 +9,7 @@ pub struct HealthCheckResponse { pub uptime: i64, #[serde(skip_serializing_if = "Option::is_none")] pub stats: Option, - pub models: Vec, + pub models: Vec<&'static str>, pub endpoints: Vec<&'static str>, } diff --git a/src/common/model/tri.rs b/src/common/model/tri.rs index ec6ebb1..91aedf0 100644 --- a/src/common/model/tri.rs +++ b/src/common/model/tri.rs @@ -18,8 +18,9 @@ impl TriState { // matches!(self, TriState::Null) // } - pub fn is_none(&self) -> bool { - matches!(self, TriState::None) + #[inline(always)] + pub const fn is_none(&self) -> bool { + matches!(*self, TriState::None) } } diff --git a/src/common/utils.rs b/src/common/utils.rs index ffb42d6..f0d59e7 100644 --- a/src/common/utils.rs +++ b/src/common/utils.rs @@ -17,15 +17,22 @@ use super::model::{ use crate::{ app::{ constant::{COMMA, FALSE, TRUE}, - lazy::{TOKEN_DELIMITER, USE_COMMA_DELIMITER, cursor_api2_chat_models_url}, + lazy::{ + TOKEN_DELIMITER, USE_COMMA_DELIMITER, cursor_api2_chat_models_url, + cursor_api2_token_usage_url, + }, model::proxy_pool::ProxyPool, }, - chat::{ - aiserver::v1::{AvailableModelsRequest, AvailableModelsResponse}, + cursor::{ + aiserver::v1::{ + AvailableModelsRequest, AvailableModelsResponse, GetTokenUsageRequest, + GetTokenUsageResponse, + }, + config::key_config, constant::{ ANTHROPIC, CREATED, CURSOR, DEEPSEEK, GOOGLE, MODEL_OBJECT, OPENAI, UNKNOWN, XAI, }, - model::Model, + model::{Model, Usage}, }, }; @@ -69,6 +76,19 @@ pub trait TrimNewlines { fn trim_leading_newlines(self) -> Self; } +impl TrimNewlines for &str { + #[inline(always)] + fn trim_leading_newlines(self) -> Self { + let bytes = self.as_bytes(); + if bytes.len() >= 2 && bytes[0] == b'\n' && bytes[1] == b'\n' { + unsafe { + return self.get_unchecked(2..) + } + } + self + } +} + impl TrimNewlines for String { #[inline(always)] fn trim_leading_newlines(mut self) -> Self { @@ -206,11 +226,8 @@ pub async fn get_available_models( available_models .models .into_iter() - .map(|model| Model { - id: model.name.clone(), - created: CREATED, - object: MODEL_OBJECT, - owned_by: { + .map(|model| { + let owned_by = { let mut chars = model.name.chars(); match chars.next() { Some('g') => match chars.next() { @@ -236,12 +253,62 @@ pub async fn get_available_models( // 其他情况 _ => UNKNOWN, } - }, + }; + + Model { + id: crate::leak::intern_string(model.name), + created: CREATED, + object: MODEL_OBJECT, + owned_by, + } }) .collect(), ) } +pub async fn get_token_usage( + client: Client, + auth_token: &str, + checksum: &str, + client_key: &str, + timezone: &'static str, + is_pri: bool, + usage_uuid: String, +) -> Option { + let response = { + let trace_id = uuid::Uuid::new_v4().to_string(); + let client = super::client::build_request(super::client::AiServiceRequest { + client, + auth_token, + checksum, + client_key, + url: cursor_api2_token_usage_url(is_pri), + is_stream: false, + timezone, + trace_id: &trace_id, + is_pri, + }); + let request = GetTokenUsageRequest { usage_uuid }; + client + .body(encode_message(&request, false).unwrap()) + .send() + .await + .ok()? + .bytes() + .await + .ok()? + }; + let token_usage = GetTokenUsageResponse::decode(response.as_ref()).ok()?; + let prompt_tokens = token_usage.input_tokens; + let completion_tokens = token_usage.output_tokens; + let total_tokens = prompt_tokens + completion_tokens; + Some(Usage { + prompt_tokens, + completion_tokens, + total_tokens, + }) +} + pub fn validate_token_and_checksum(auth_token: &str) -> Option<(String, String)> { // 尝试使用自定义分隔符查找 let mut delimiter_pos = auth_token.rfind(*TOKEN_DELIMITER); @@ -319,12 +386,11 @@ pub fn extract_token(auth_token: &str) -> Option { } } +#[inline(always)] pub fn format_time_ms(seconds: f64) -> f64 { (seconds * 1000.0).round() / 1000.0 } -use crate::chat::config::key_config; - /// 将 JWT token 转换为 TokenInfo pub fn token_to_tokeninfo( auth_token: &str, @@ -408,6 +474,7 @@ pub fn tokeninfo_to_token(mut info: key_config::TokenInfo) -> Option<(String, St )) } +#[inline(always)] pub fn encode_message( message: &impl prost::Message, with_gzip: bool, diff --git a/src/common/utils/checksum.rs b/src/common/utils/checksum.rs index 6982907..0e90b0d 100644 --- a/src/common/utils/checksum.rs +++ b/src/common/utils/checksum.rs @@ -1,9 +1,9 @@ use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD as BASE64}; -use rand::Rng as _; use sha2::{Digest, Sha256}; #[inline] pub fn generate_hash() -> String { + use rand::Rng as _; hex::encode( Sha256::new() .chain_update(rand::rng().random::<[u8; 32]>()) diff --git a/src/chat.rs b/src/cursor.rs similarity index 100% rename from src/chat.rs rename to src/cursor.rs diff --git a/src/chat/adapter.rs b/src/cursor/adapter.rs similarity index 93% rename from src/chat/adapter.rs rename to src/cursor/adapter.rs index f1f2d2f..06f1ba2 100644 --- a/src/chat/adapter.rs +++ b/src/cursor/adapter.rs @@ -89,7 +89,7 @@ fn parse_web_references(text: &str) -> Vec { async fn process_chat_inputs( inputs: Vec, disable_vision: bool, - model_name: &str, + model: &str, ) -> (String, Vec, Vec) { // 收集 system 指令 let instructions = inputs @@ -100,7 +100,7 @@ async fn process_chat_inputs( MessageContent::Vision(contents) => contents .iter() .filter_map(|content| { - if content.content_type == "text" { + if content.rtype == "text" { content.text.clone() } else { None @@ -113,9 +113,9 @@ async fn process_chat_inputs( .join("\n\n"); // 使用默认指令或收集到的指令 - let image_support = !disable_vision && SUPPORTED_IMAGE_MODELS.contains(&model_name); + let image_support = !disable_vision && SUPPORTED_IMAGE_MODELS.contains(&model); let instructions = if instructions.is_empty() { - get_default_instructions(model_name, image_support) + get_default_instructions(model, image_support) } else { instructions }; @@ -174,6 +174,15 @@ async fn process_chat_inputs( attached_human_changes: false, summarized_composers: vec![], cursor_rules: vec![], + context_pieces: vec![], + thinking: None, + all_thinking_blocks: vec![], + unified_mode: None, + diffs_since_last_apply: vec![], + deleted_files: vec![], + usage_uuid: None, + supported_tools: vec![], + current_file_location_data: None, }], vec![], ); @@ -229,7 +238,7 @@ async fn process_chat_inputs( let mut images = Vec::new(); for content in contents { - match content.content_type.as_str() { + match content.rtype.as_str() { "text" => { if let Some(text) = content.text { text_parts.push(text); @@ -322,6 +331,15 @@ async fn process_chat_inputs( attached_human_changes: false, summarized_composers: vec![], cursor_rules: vec![], + context_pieces: vec![], + thinking: None, + all_thinking_blocks: vec![], + unified_mode: None, + diffs_since_last_apply: vec![], + deleted_files: vec![], + usage_uuid: None, + supported_tools: vec![], + current_file_location_data: None, }); } @@ -473,7 +491,7 @@ async fn process_http_image( pub async fn encode_chat_message( inputs: Vec, - model_name: &str, + model: &str, disable_vision: bool, enable_slow_pool: bool, is_search: bool, @@ -481,20 +499,20 @@ pub async fn encode_chat_message( // 在进入异步操作前获取并释放锁 let enable_slow_pool = { if enable_slow_pool { Some(true) } else { None } }; - let (instructions, messages, urls) = - process_chat_inputs(inputs, disable_vision, model_name).await; + let (instructions, messages, urls) = process_chat_inputs(inputs, disable_vision, model).await; let explicit_context = if !instructions.trim().is_empty() { Some(ExplicitContext { context: instructions, repo_context: None, rules: vec![], + mode_specific_context: None, }) } else { None }; - let base_uuid = rand::rng().random::(); + let base_uuid = rand::rng().random_range(256u16..512); let external_links = urls .into_iter() .enumerate() @@ -515,7 +533,7 @@ pub async fn encode_chat_message( workspace_root_path: None, code_blocks: vec![], model_details: Some(ModelDetails { - model_name: Some(model_name.to_string()), + model_name: Some(model.to_string()), api_key: None, enable_ghost_mode: Some(true), azure_state: Some(AzureState { @@ -546,7 +564,9 @@ pub async fn encode_chat_message( workspace_id: None, external_links, commit_notes: vec![], - long_context_mode: Some(LONG_CONTEXT_MODELS.contains(&model_name)), + long_context_mode: Some( + AppConfig::get_long_context() || LONG_CONTEXT_MODELS.contains(&model), + ), is_eval: Some(false), desired_max_tokens: None, context_ast: None, diff --git a/src/chat/aiserver.rs b/src/cursor/aiserver.rs similarity index 100% rename from src/chat/aiserver.rs rename to src/cursor/aiserver.rs diff --git a/src/chat/aiserver/v1.rs b/src/cursor/aiserver/v1.rs similarity index 62% rename from src/chat/aiserver/v1.rs rename to src/cursor/aiserver/v1.rs index 711cca0..5346c11 100644 --- a/src/chat/aiserver/v1.rs +++ b/src/cursor/aiserver/v1.rs @@ -6,24 +6,30 @@ impl ErrorDetails { pub fn status_code(&self) -> u16 { match Error::try_from(self.error) { Ok(error) => match error { - Error::Unspecified => 500, + // 认证/授权相关错误 Error::BadApiKey | Error::BadUserApiKey | Error::InvalidAuthId | Error::AuthTokenNotFound | Error::AuthTokenExpired | Error::Unauthorized => 401, + + // 权限不足 Error::NotLoggedIn | Error::NotHighEnoughPermissions | Error::AgentRequiresLogin | Error::ProUserOnly | Error::TaskNoPermissions => 403, + + // 资源未找到 Error::NotFound | Error::UserNotFound | Error::TaskUuidNotFound | Error::AgentEngineNotFound | Error::GitgraphNotFound | Error::FileNotFound => 404, + + // 请求过多/速率限制 Error::FreeUserRateLimitExceeded | Error::ProUserRateLimitExceeded | Error::OpenaiRateLimitExceeded @@ -31,25 +37,44 @@ impl ErrorDetails { | Error::GenericRateLimitExceeded | Error::Gpt4VisionPreviewRateLimit | Error::ApiKeyRateLimit => 429, + + // 客户端请求错误 Error::BadRequest | Error::BadModelName | Error::SlashEditFileTooLong | Error::FileUnsupported | Error::ClaudeImageTooLarge | Error::ConversationTooLong => 400, + + // 超时 Error::Timeout => 504, - Error::Deprecated - | Error::FreeUserUsageLimit + + // 版本/弃用相关 + Error::Deprecated | Error::OutdatedClient => 410, + + // 资源耗尽/配额限制 + Error::FreeUserUsageLimit | Error::ProUserUsageLimit | Error::ResourceExhausted - | Error::Openai - | Error::MaxTokens - | Error::ApiKeyNotSupported - | Error::UserAbortedRequest - | Error::CustomMessage - | Error::OutdatedClient - | Error::Debounced - | Error::RepositoryServiceRepositoryIsNotInitialized => 500, + | Error::MaxTokens => 503, + + // OpenAI相关错误 + Error::Openai | Error::ApiKeyNotSupported => 500, + + // 客户端主动取消 + Error::UserAbortedRequest => 500, + + // 自定义消息 + Error::CustomMessage => 500, + + // 价格相关 + Error::UsagePricingRequired | Error::UsagePricingRequiredChangeable => 402, + + // 代码/仓库相关 + Error::RepositoryServiceRepositoryIsNotInitialized => 500, + + // 其他/未分类的服务器内部错误 + Error::Unspecified | Error::Debounced => 500, }, Err(_) => 500, } diff --git a/src/chat/aiserver/v1/aiserver.v1.rs b/src/cursor/aiserver/v1/aiserver.v1.rs similarity index 85% rename from src/chat/aiserver/v1/aiserver.v1.rs rename to src/cursor/aiserver/v1/aiserver.v1.rs index 84ba1d9..e62600f 100644 --- a/src/chat/aiserver/v1/aiserver.v1.rs +++ b/src/cursor/aiserver/v1/aiserver.v1.rs @@ -1,35 +1,401 @@ -/// aiserver.v1.AvailableModelsRequest +/// aiserver.v1.CursorPosition #[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct AvailableModelsRequest { - #[prost(bool, tag = "1")] - pub is_nightly: bool, - #[prost(bool, tag = "2")] - pub include_long_context_models: bool, +pub struct CursorPosition { + #[prost(int32, tag = "1")] + pub line: i32, + #[prost(int32, tag = "2")] + pub column: i32, } -/// aiserver.v1.AvailableModelsResponse +/// aiserver.v1.SimplestRange +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct SimplestRange { + #[prost(int32, tag = "1")] + pub start_line: i32, + #[prost(int32, tag = "2")] + pub end_line_inclusive: i32, +} +/// aiserver.v1.GitDiff #[derive(Clone, PartialEq, ::prost::Message)] -pub struct AvailableModelsResponse { - #[prost(message, repeated, tag = "2")] - pub models: ::prost::alloc::vec::Vec, - #[prost(string, repeated, tag = "1")] - pub model_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +pub struct GitDiff { + #[prost(message, repeated, tag = "1")] + pub diffs: ::prost::alloc::vec::Vec, + #[prost(enumeration = "git_diff::DiffType", tag = "2")] + pub diff_type: i32, } -/// Nested message and enum types in `AvailableModelsResponse`. -pub mod available_models_response { - /// aiserver.v1.AvailableModelsResponse.AvailableModel - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct AvailableModel { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(bool, tag = "2")] - pub default_on: bool, - #[prost(bool, optional, tag = "3")] - pub is_long_context_only: ::core::option::Option, - #[prost(bool, optional, tag = "4")] - pub is_chat_only: ::core::option::Option, - #[prost(bool, optional, tag = "5")] - pub supports_agent: ::core::option::Option, +/// Nested message and enum types in `GitDiff`. +pub mod git_diff { + /// aiserver.v1.GitDiff.DiffType + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum DiffType { + Unspecified = 0, + DiffToHead = 1, + DiffFromBranchToMain = 2, } + impl DiffType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "DIFF_TYPE_UNSPECIFIED", + Self::DiffToHead => "DIFF_TYPE_DIFF_TO_HEAD", + Self::DiffFromBranchToMain => "DIFF_TYPE_DIFF_FROM_BRANCH_TO_MAIN", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "DIFF_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "DIFF_TYPE_DIFF_TO_HEAD" => Some(Self::DiffToHead), + "DIFF_TYPE_DIFF_FROM_BRANCH_TO_MAIN" => Some(Self::DiffFromBranchToMain), + _ => None, + } + } + } +} +/// aiserver.v1.FileDiff +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FileDiff { + #[prost(string, tag = "1")] + pub from: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub to: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "3")] + pub chunks: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `FileDiff`. +pub mod file_diff { + /// aiserver.v1.FileDiff.Chunk + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Chunk { + #[prost(string, tag = "1")] + pub content: ::prost::alloc::string::String, + #[prost(string, repeated, tag = "2")] + pub lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(int32, tag = "3")] + pub old_start: i32, + #[prost(int32, tag = "4")] + pub old_lines: i32, + #[prost(int32, tag = "5")] + pub new_start: i32, + #[prost(int32, tag = "6")] + pub new_lines: i32, + } +} +/// aiserver.v1.LineRange +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct LineRange { + #[prost(int32, tag = "1")] + pub start_line_number: i32, + #[prost(int32, tag = "2")] + pub end_line_number_inclusive: i32, +} +/// aiserver.v1.CursorRange +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct CursorRange { + #[prost(message, optional, tag = "1")] + pub start_position: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub end_position: ::core::option::Option, +} +/// aiserver.v1.DetailedLine +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DetailedLine { + #[prost(string, tag = "1")] + pub text: ::prost::alloc::string::String, + #[prost(float, tag = "2")] + pub line_number: f32, + #[prost(bool, tag = "3")] + pub is_signature: bool, +} +/// aiserver.v1.CodeBlock +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CodeBlock { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(string, optional, tag = "2")] + pub file_contents: ::core::option::Option<::prost::alloc::string::String>, + #[prost(int32, optional, tag = "9")] + pub file_contents_length: ::core::option::Option, + #[prost(message, optional, tag = "3")] + pub range: ::core::option::Option, + #[prost(string, tag = "4")] + pub contents: ::prost::alloc::string::String, + #[prost(message, optional, tag = "5")] + pub signatures: ::core::option::Option, + #[prost(string, optional, tag = "6")] + pub override_contents: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag = "7")] + pub original_contents: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "8")] + pub detailed_lines: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `CodeBlock`. +pub mod code_block { + /// aiserver.v1.CodeBlock.Signatures + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Signatures { + #[prost(message, repeated, tag = "1")] + pub ranges: ::prost::alloc::vec::Vec, + } +} +/// aiserver.v1.File +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct File { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub contents: ::prost::alloc::string::String, +} +/// aiserver.v1.Diagnostic +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Diagnostic { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub range: ::core::option::Option, + #[prost(enumeration = "diagnostic::DiagnosticSeverity", tag = "3")] + pub severity: i32, + #[prost(message, repeated, tag = "4")] + pub related_information: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `Diagnostic`. +pub mod diagnostic { + /// aiserver.v1.Diagnostic.RelatedInformation + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct RelatedInformation { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub range: ::core::option::Option, + } + /// aiserver.v1.Diagnostic.DiagnosticSeverity + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum DiagnosticSeverity { + Unspecified = 0, + Error = 1, + Warning = 2, + Information = 3, + Hint = 4, + } + impl DiagnosticSeverity { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "DIAGNOSTIC_SEVERITY_UNSPECIFIED", + Self::Error => "DIAGNOSTIC_SEVERITY_ERROR", + Self::Warning => "DIAGNOSTIC_SEVERITY_WARNING", + Self::Information => "DIAGNOSTIC_SEVERITY_INFORMATION", + Self::Hint => "DIAGNOSTIC_SEVERITY_HINT", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "DIAGNOSTIC_SEVERITY_UNSPECIFIED" => Some(Self::Unspecified), + "DIAGNOSTIC_SEVERITY_ERROR" => Some(Self::Error), + "DIAGNOSTIC_SEVERITY_WARNING" => Some(Self::Warning), + "DIAGNOSTIC_SEVERITY_INFORMATION" => Some(Self::Information), + "DIAGNOSTIC_SEVERITY_HINT" => Some(Self::Hint), + _ => None, + } + } + } +} +/// aiserver.v1.BM25Chunk +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Bm25Chunk { + #[prost(string, tag = "1")] + pub content: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub range: ::core::option::Option, + #[prost(int32, tag = "3")] + pub score: i32, + #[prost(string, tag = "4")] + pub relative_path: ::prost::alloc::string::String, +} +/// aiserver.v1.CurrentFileInfo +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CurrentFileInfo { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub contents: ::prost::alloc::string::String, + #[prost(bool, tag = "18")] + pub rely_on_filesync: bool, + #[prost(string, optional, tag = "17")] + pub sha_256_hash: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "16")] + pub cells: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "10")] + pub top_chunks: ::prost::alloc::vec::Vec, + #[prost(int32, tag = "9")] + pub contents_start_at_line: i32, + #[prost(message, optional, tag = "3")] + pub cursor_position: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + pub dataframes: ::prost::alloc::vec::Vec, + #[prost(int32, tag = "8")] + pub total_number_of_lines: i32, + #[prost(string, tag = "5")] + pub language_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "6")] + pub selection: ::core::option::Option, + #[prost(int32, optional, tag = "11")] + pub alternative_version_id: ::core::option::Option, + #[prost(message, repeated, tag = "7")] + pub diagnostics: ::prost::alloc::vec::Vec, + #[prost(int32, optional, tag = "14")] + pub file_version: ::core::option::Option, + #[prost(int32, repeated, tag = "15")] + pub cell_start_lines: ::prost::alloc::vec::Vec, + #[prost(string, tag = "19")] + pub workspace_root_path: ::prost::alloc::string::String, +} +/// Nested message and enum types in `CurrentFileInfo`. +pub mod current_file_info { + /// aiserver.v1.CurrentFileInfo.NotebookCell + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct NotebookCell {} +} +/// aiserver.v1.AzureState +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AzureState { + #[prost(string, tag = "1")] + pub api_key: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub base_url: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub deployment: ::prost::alloc::string::String, + #[prost(bool, tag = "4")] + pub use_azure: bool, +} +/// aiserver.v1.ModelDetails +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ModelDetails { + #[prost(string, optional, tag = "1")] + pub model_name: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag = "2")] + pub api_key: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bool, optional, tag = "3")] + pub enable_ghost_mode: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub azure_state: ::core::option::Option, + #[prost(bool, optional, tag = "5")] + pub enable_slow_pool: ::core::option::Option, + #[prost(string, optional, tag = "6")] + pub openai_api_base_url: ::core::option::Option<::prost::alloc::string::String>, +} +/// aiserver.v1.DataframeInfo +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DataframeInfo { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub shape: ::prost::alloc::string::String, + #[prost(int32, tag = "3")] + pub data_dimensionality: i32, + #[prost(message, repeated, tag = "6")] + pub columns: ::prost::alloc::vec::Vec, + #[prost(int32, tag = "7")] + pub row_count: i32, + #[prost(string, tag = "8")] + pub index_column: ::prost::alloc::string::String, +} +/// Nested message and enum types in `DataframeInfo`. +pub mod dataframe_info { + /// aiserver.v1.DataframeInfo.Column + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Column { + #[prost(string, tag = "1")] + pub key: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub r#type: ::prost::alloc::string::String, + } +} +/// aiserver.v1.LinterError +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LinterError { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub range: ::core::option::Option, + #[prost(string, optional, tag = "3")] + pub source: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "4")] + pub related_information: ::prost::alloc::vec::Vec, + #[prost(enumeration = "diagnostic::DiagnosticSeverity", optional, tag = "5")] + pub severity: ::core::option::Option, +} +/// aiserver.v1.LinterErrors +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LinterErrors { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub errors: ::prost::alloc::vec::Vec, + #[prost(string, tag = "3")] + pub file_contents: ::prost::alloc::string::String, +} +/// aiserver.v1.LinterErrorsWithoutFileContents +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct LinterErrorsWithoutFileContents { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub errors: ::prost::alloc::vec::Vec, +} +/// aiserver.v1.CursorRule +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CursorRule { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub description: ::prost::alloc::string::String, + #[prost(string, optional, tag = "3")] + pub body: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bool, optional, tag = "4")] + pub is_from_glob: ::core::option::Option, + #[prost(bool, optional, tag = "5")] + pub always_apply: ::core::option::Option, +} +/// aiserver.v1.ExplicitContext +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ExplicitContext { + #[prost(string, tag = "1")] + pub context: ::prost::alloc::string::String, + #[prost(string, optional, tag = "2")] + pub repo_context: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "3")] + pub rules: ::prost::alloc::vec::Vec, + #[prost(string, optional, tag = "4")] + pub mode_specific_context: ::core::option::Option<::prost::alloc::string::String>, } /// aiserver.v1.ErrorDetails #[derive(Clone, PartialEq, ::prost::Message)] @@ -44,7 +410,6 @@ pub struct ErrorDetails { /// Nested message and enum types in `ErrorDetails`. pub mod error_details { /// aiserver.v1.ErrorDetails.Error - #[allow(clippy::enum_variant_names)] #[derive( Clone, Copy, @@ -102,6 +467,8 @@ pub mod error_details { RepositoryServiceRepositoryIsNotInitialized = 37, Unauthorized = 38, ConversationTooLong = 43, + UsagePricingRequired = 44, + UsagePricingRequiredChangeable = 45, } impl Error { /// String value of the enum field names used in the ProtoBuf definition. @@ -158,6 +525,10 @@ pub mod error_details { } Self::Unauthorized => "ERROR_UNAUTHORIZED", Self::ConversationTooLong => "ERROR_CONVERSATION_TOO_LONG", + Self::UsagePricingRequired => "ERROR_USAGE_PRICING_REQUIRED", + Self::UsagePricingRequiredChangeable => { + "ERROR_USAGE_PRICING_REQUIRED_CHANGEABLE" + } } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -221,6 +592,10 @@ pub mod error_details { } "ERROR_UNAUTHORIZED" => Some(Self::Unauthorized), "ERROR_CONVERSATION_TOO_LONG" => Some(Self::ConversationTooLong), + "ERROR_USAGE_PRICING_REQUIRED" => Some(Self::UsagePricingRequired), + "ERROR_USAGE_PRICING_REQUIRED_CHANGEABLE" => { + Some(Self::UsagePricingRequiredChangeable) + } _ => None, } } @@ -244,73 +619,161 @@ pub struct CustomErrorDetails { #[prost(bool, optional, tag = "6")] pub should_show_immediate_error: ::core::option::Option, } -/// aiserver.v1.GetChatRequest +/// aiserver.v1.ImageProto #[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetChatRequest { +pub struct ImageProto { + #[prost(bytes = "vec", tag = "1")] + pub data: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "2")] + pub dimension: ::core::option::Option, +} +/// Nested message and enum types in `ImageProto`. +pub mod image_proto { + /// aiserver.v1.ImageProto.Dimension + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct Dimension { + #[prost(int32, tag = "1")] + pub width: i32, + #[prost(int32, tag = "2")] + pub height: i32, + } +} +/// aiserver.v1.ChatQuote +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ChatQuote { + #[prost(string, tag = "1")] + pub markdown: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub bubble_id: ::prost::alloc::string::String, + #[prost(int32, tag = "3")] + pub section_index: i32, +} +/// aiserver.v1.ChatExternalLink +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ChatExternalLink { + #[prost(string, tag = "1")] + pub url: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub uuid: ::prost::alloc::string::String, +} +/// aiserver.v1.CommitNote +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CommitNote { + #[prost(string, tag = "1")] + pub note: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub commit_hash: ::prost::alloc::string::String, +} +/// aiserver.v1.CodeChunk +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CodeChunk { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub start_line_number: i32, + #[prost(string, repeated, tag = "3")] + pub lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(enumeration = "code_chunk::SummarizationStrategy", optional, tag = "4")] + pub summarization_strategy: ::core::option::Option, + #[prost(string, tag = "5")] + pub language_identifier: ::prost::alloc::string::String, + #[prost(enumeration = "code_chunk::Intent", optional, tag = "6")] + pub intent: ::core::option::Option, + #[prost(bool, optional, tag = "7")] + pub is_final_version: ::core::option::Option, + #[prost(bool, optional, tag = "8")] + pub is_first_version: ::core::option::Option, +} +/// Nested message and enum types in `CodeChunk`. +pub mod code_chunk { + /// aiserver.v1.CodeChunk.Intent + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Intent { + Unspecified = 0, + ComposerFile = 1, + CompressedComposerFile = 2, + } + impl Intent { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "INTENT_UNSPECIFIED", + Self::ComposerFile => "INTENT_COMPOSER_FILE", + Self::CompressedComposerFile => "INTENT_COMPRESSED_COMPOSER_FILE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "INTENT_UNSPECIFIED" => Some(Self::Unspecified), + "INTENT_COMPOSER_FILE" => Some(Self::ComposerFile), + "INTENT_COMPRESSED_COMPOSER_FILE" => Some(Self::CompressedComposerFile), + _ => None, + } + } + } + /// aiserver.v1.CodeChunk.SummarizationStrategy + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum SummarizationStrategy { + NoneUnspecified = 0, + Summarized = 1, + Embedded = 2, + } + impl SummarizationStrategy { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::NoneUnspecified => "SUMMARIZATION_STRATEGY_NONE_UNSPECIFIED", + Self::Summarized => "SUMMARIZATION_STRATEGY_SUMMARIZED", + Self::Embedded => "SUMMARIZATION_STRATEGY_EMBEDDED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "SUMMARIZATION_STRATEGY_NONE_UNSPECIFIED" => Some(Self::NoneUnspecified), + "SUMMARIZATION_STRATEGY_SUMMARIZED" => Some(Self::Summarized), + "SUMMARIZATION_STRATEGY_EMBEDDED" => Some(Self::Embedded), + _ => None, + } + } + } +} +/// aiserver.v1.CodeResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct CodeResult { #[prost(message, optional, tag = "1")] - pub current_file: ::core::option::Option, - #[prost(message, repeated, tag = "2")] - pub conversation: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "3")] - pub repositories: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "4")] - pub explicit_context: ::core::option::Option, - #[prost(string, optional, tag = "5")] - pub workspace_root_path: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "6")] - pub code_blocks: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "7")] - pub model_details: ::core::option::Option, - #[prost(string, repeated, tag = "8")] - pub documentation_identifiers: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, - #[prost(string, tag = "9")] - pub request_id: ::prost::alloc::string::String, - #[prost(message, optional, tag = "10")] - pub linter_errors: ::core::option::Option, - #[prost(string, optional, tag = "11")] - pub summary: ::core::option::Option<::prost::alloc::string::String>, - #[prost(int32, optional, tag = "12")] - pub summary_up_until_index: ::core::option::Option, - #[prost(bool, optional, tag = "13")] - pub allow_long_file_scan: ::core::option::Option, - #[prost(bool, optional, tag = "14")] - pub is_bash: ::core::option::Option, - #[prost(string, tag = "15")] - pub conversation_id: ::prost::alloc::string::String, - #[prost(bool, optional, tag = "16")] - pub can_handle_filenames_after_language_ids: ::core::option::Option, - #[prost(string, optional, tag = "17")] - pub use_web: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "18")] - pub quotes: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "19")] - pub debug_info: ::core::option::Option, - #[prost(string, optional, tag = "20")] - pub workspace_id: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "21")] - pub external_links: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "23")] - pub commit_notes: ::prost::alloc::vec::Vec, - #[prost(bool, optional, tag = "22")] - pub long_context_mode: ::core::option::Option, - #[prost(bool, optional, tag = "24")] - pub is_eval: ::core::option::Option, - #[prost(int32, optional, tag = "26")] - pub desired_max_tokens: ::core::option::Option, - #[prost(message, optional, tag = "25")] - pub context_ast: ::core::option::Option, - #[prost(bool, optional, tag = "27")] - pub is_composer: ::core::option::Option, - #[prost(bool, optional, tag = "28")] - pub runnable_code_blocks: ::core::option::Option, - #[prost(bool, optional, tag = "29")] - pub should_cache: ::core::option::Option, - #[prost(bool, optional, tag = "30")] - pub allow_model_fallbacks: ::core::option::Option, - #[prost(int32, optional, tag = "31")] - pub number_of_times_shown_fallback_model_warning: ::core::option::Option, + pub code_block: ::core::option::Option, + #[prost(float, tag = "2")] + pub score: f32, } /// aiserver.v1.RepositoryInfo #[derive(Clone, PartialEq, ::prost::Message)] @@ -335,267 +798,564 @@ pub struct RepositoryInfo { pub orthogonal_transform_seed: ::core::option::Option, #[prost(enumeration = "EmbeddingModel", optional, tag = "10")] pub preferred_embedding_model: ::core::option::Option, + #[prost(string, tag = "11")] + pub workspace_uri: ::prost::alloc::string::String, } -/// aiserver.v1.ModelDetails +/// aiserver.v1.ReapplyResult #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ModelDetails { - #[prost(string, optional, tag = "1")] - pub model_name: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "2")] - pub api_key: ::core::option::Option<::prost::alloc::string::String>, - #[prost(bool, optional, tag = "3")] - pub enable_ghost_mode: ::core::option::Option, - #[prost(message, optional, tag = "4")] - pub azure_state: ::core::option::Option, - #[prost(bool, optional, tag = "5")] - pub enable_slow_pool: ::core::option::Option, - #[prost(string, optional, tag = "6")] - pub openai_api_base_url: ::core::option::Option<::prost::alloc::string::String>, -} -/// aiserver.v1.AzureState -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct AzureState { - #[prost(string, tag = "1")] - pub api_key: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub base_url: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub deployment: ::prost::alloc::string::String, - #[prost(bool, tag = "4")] - pub use_azure: bool, -} -/// aiserver.v1.LinterErrors -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LinterErrors { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub errors: ::prost::alloc::vec::Vec, - #[prost(string, tag = "3")] - pub file_contents: ::prost::alloc::string::String, -} -/// aiserver.v1.LinterError -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LinterError { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub range: ::core::option::Option, - #[prost(string, optional, tag = "3")] - pub source: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "4")] - pub related_information: ::prost::alloc::vec::Vec, - #[prost(enumeration = "diagnostic::DiagnosticSeverity", optional, tag = "5")] - pub severity: ::core::option::Option, -} -/// aiserver.v1.CursorRange -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct CursorRange { +pub struct ReapplyResult { #[prost(message, optional, tag = "1")] - pub start_position: ::core::option::Option, - #[prost(message, optional, tag = "2")] - pub end_position: ::core::option::Option, + pub diff: ::core::option::Option, + #[prost(bool, tag = "2")] + pub is_applied: bool, + #[prost(bool, tag = "3")] + pub apply_failed: bool, + #[prost(message, repeated, tag = "4")] + pub linter_errors: ::prost::alloc::vec::Vec, + #[prost(bool, optional, tag = "5")] + pub rejected: ::core::option::Option, } -/// aiserver.v1.CursorPosition -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct CursorPosition { - #[prost(int32, tag = "1")] - pub line: i32, - #[prost(int32, tag = "2")] - pub column: i32, -} -/// aiserver.v1.ExplicitContext +/// aiserver.v1.FetchRulesResult #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ExplicitContext { - #[prost(string, tag = "1")] - pub context: ::prost::alloc::string::String, - #[prost(string, optional, tag = "2")] - pub repo_context: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "3")] +pub struct FetchRulesResult { + #[prost(message, repeated, tag = "1")] pub rules: ::prost::alloc::vec::Vec, } -/// aiserver.v1.CursorRule +/// aiserver.v1.PlannerResult #[derive(Clone, PartialEq, ::prost::Message)] -pub struct CursorRule { +pub struct PlannerResult { #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, + pub plan: ::prost::alloc::string::String, +} +/// aiserver.v1.GetRelatedFilesResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetRelatedFilesResult { + #[prost(message, repeated, tag = "1")] + pub files: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `GetRelatedFilesResult`. +pub mod get_related_files_result { + /// aiserver.v1.GetRelatedFilesResult.File + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct File { + #[prost(string, tag = "1")] + pub uri: ::prost::alloc::string::String, + #[prost(float, tag = "2")] + pub score: f32, + } +} +/// aiserver.v1.ToolResultError +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ToolResultError { + #[prost(string, tag = "1")] + pub client_visible_error_message: ::prost::alloc::string::String, #[prost(string, tag = "2")] - pub description: ::prost::alloc::string::String, + pub model_visible_error_message: ::prost::alloc::string::String, #[prost(string, optional, tag = "3")] - pub body: ::core::option::Option<::prost::alloc::string::String>, - #[prost(bool, optional, tag = "4")] - pub is_from_glob: ::core::option::Option, + pub actual_error_message_only_send_from_client_to_server_never_the_other_way_around_because_that_may_be_a_security_risk: ::core::option::Option< + ::prost::alloc::string::String, + >, } -/// aiserver.v1.DebugInfo +/// aiserver.v1.ClientSideToolV2Result #[derive(Clone, PartialEq, ::prost::Message)] -pub struct DebugInfo { +pub struct ClientSideToolV2Result { + #[prost(enumeration = "ClientSideToolV2", tag = "1")] + pub tool: i32, + #[prost(message, optional, tag = "8")] + pub error: ::core::option::Option, + #[prost( + oneof = "client_side_tool_v2_result::Result", + tags = "2, 3, 4, 5, 6, 9, 10, 11, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33" + )] + pub result: ::core::option::Option, +} +/// Nested message and enum types in `ClientSideToolV2Result`. +pub mod client_side_tool_v2_result { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(message, tag = "2")] + ReadSemsearchFilesResult(super::ReadSemsearchFilesResult), + #[prost(message, tag = "3")] + ReadFileForImportsResult(super::ReadFileForImportsResult), + #[prost(message, tag = "4")] + RipgrepSearchResult(super::RipgrepSearchResult), + #[prost(message, tag = "5")] + RunTerminalCommandResult(super::RunTerminalCommandResult), + #[prost(message, tag = "6")] + ReadFileResult(super::ReadFileResult), + #[prost(message, tag = "9")] + ListDirResult(super::ListDirResult), + #[prost(message, tag = "10")] + EditFileResult(super::EditFileResult), + #[prost(message, tag = "11")] + FileSearchResult(super::ToolCallFileSearchResult), + #[prost(message, tag = "18")] + SemanticSearchFullResult(super::SemanticSearchFullResult), + #[prost(message, tag = "19")] + CreateFileResult(super::CreateFileResult), + #[prost(message, tag = "20")] + DeleteFileResult(super::DeleteFileResult), + #[prost(message, tag = "21")] + ReapplyResult(super::ReapplyResult), + #[prost(message, tag = "22")] + GetRelatedFilesResult(super::GetRelatedFilesResult), + #[prost(message, tag = "23")] + ParallelApplyResult(super::ParallelApplyResult), + #[prost(message, tag = "24")] + RunTerminalCommandV2Result(super::RunTerminalCommandV2Result), + #[prost(message, tag = "25")] + FetchRulesResult(super::FetchRulesResult), + #[prost(message, tag = "26")] + PlannerResult(super::PlannerResult), + #[prost(message, tag = "27")] + WebSearchResult(super::WebSearchResult), + #[prost(message, tag = "28")] + McpResult(super::McpResult), + #[prost(message, tag = "29")] + WebViewerResult(super::WebViewerResult), + #[prost(message, tag = "30")] + DiffHistoryResult(super::DiffHistoryResult), + #[prost(message, tag = "31")] + ImplementerResult(super::ImplementerResult), + #[prost(message, tag = "32")] + SearchSymbolsResult(super::SearchSymbolsResult), + #[prost(message, tag = "33")] + BackgroundComposerFollowupResult(super::BackgroundComposerFollowupResult), + } +} +/// aiserver.v1.EditFileResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct EditFileResult { #[prost(message, optional, tag = "1")] - pub breakpoint: ::core::option::Option, - #[prost(message, repeated, tag = "2")] - pub call_stack: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "3")] - pub history: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `DebugInfo`. -pub mod debug_info { - /// aiserver.v1.DebugInfo.Variable - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Variable { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub value: ::prost::alloc::string::String, - #[prost(string, optional, tag = "3")] - pub r#type: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.DebugInfo.Scope - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Scope { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub variables: ::prost::alloc::vec::Vec, - } - /// aiserver.v1.DebugInfo.CallStackFrame - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct CallStackFrame { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub line_number: i32, - #[prost(string, tag = "3")] - pub function_name: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "4")] - pub scopes: ::prost::alloc::vec::Vec, - } - /// aiserver.v1.DebugInfo.Breakpoint - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Breakpoint { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub line_number: i32, - #[prost(string, repeated, tag = "3")] - pub lines_before_breakpoint: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, - #[prost(string, repeated, tag = "4")] - pub lines_after_breakpoint: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, - #[prost(string, optional, tag = "5")] - pub exception_info: ::core::option::Option<::prost::alloc::string::String>, - } -} -/// aiserver.v1.CodeBlock -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CodeBlock { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(string, optional, tag = "2")] - pub file_contents: ::core::option::Option<::prost::alloc::string::String>, - #[prost(int32, optional, tag = "9")] - pub file_contents_length: ::core::option::Option, - #[prost(message, optional, tag = "3")] - pub range: ::core::option::Option, - #[prost(string, tag = "4")] - pub contents: ::prost::alloc::string::String, - #[prost(message, optional, tag = "5")] - pub signatures: ::core::option::Option, - #[prost(string, optional, tag = "6")] - pub override_contents: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "7")] - pub original_contents: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "8")] - pub detailed_lines: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `CodeBlock`. -pub mod code_block { - /// aiserver.v1.CodeBlock.Signatures - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Signatures { - #[prost(message, repeated, tag = "1")] - pub ranges: ::prost::alloc::vec::Vec, - } -} -/// aiserver.v1.DetailedLine -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DetailedLine { - #[prost(string, tag = "1")] - pub text: ::prost::alloc::string::String, - #[prost(float, tag = "2")] - pub line_number: f32, + pub diff: ::core::option::Option, + #[prost(bool, tag = "2")] + pub is_applied: bool, #[prost(bool, tag = "3")] - pub is_signature: bool, -} -/// aiserver.v1.CurrentFileInfo -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CurrentFileInfo { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub contents: ::prost::alloc::string::String, - #[prost(bool, tag = "18")] - pub rely_on_filesync: bool, - #[prost(string, optional, tag = "17")] - pub sha_256_hash: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "16")] - pub cells: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "10")] - pub top_chunks: ::prost::alloc::vec::Vec, - #[prost(int32, tag = "9")] - pub contents_start_at_line: i32, - #[prost(message, optional, tag = "3")] - pub cursor_position: ::core::option::Option, + pub apply_failed: bool, #[prost(message, repeated, tag = "4")] - pub dataframes: ::prost::alloc::vec::Vec, - #[prost(int32, tag = "8")] - pub total_number_of_lines: i32, - #[prost(string, tag = "5")] - pub language_id: ::prost::alloc::string::String, - #[prost(message, optional, tag = "6")] - pub selection: ::core::option::Option, - #[prost(int32, optional, tag = "11")] - pub alternative_version_id: ::core::option::Option, - #[prost(message, repeated, tag = "7")] - pub diagnostics: ::prost::alloc::vec::Vec, - #[prost(int32, optional, tag = "14")] - pub file_version: ::core::option::Option, - #[prost(int32, repeated, tag = "15")] - pub cell_start_lines: ::prost::alloc::vec::Vec, - #[prost(string, tag = "19")] - pub workspace_root_path: ::prost::alloc::string::String, + pub linter_errors: ::prost::alloc::vec::Vec, + #[prost(bool, optional, tag = "5")] + pub rejected: ::core::option::Option, } -/// Nested message and enum types in `CurrentFileInfo`. -pub mod current_file_info { - /// aiserver.v1.CurrentFileInfo.NotebookCell - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct NotebookCell {} -} -/// aiserver.v1.Diagnostic -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Diagnostic { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub range: ::core::option::Option, - #[prost(enumeration = "diagnostic::DiagnosticSeverity", tag = "3")] - pub severity: i32, - #[prost(message, repeated, tag = "4")] - pub related_information: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `Diagnostic`. -pub mod diagnostic { - /// aiserver.v1.Diagnostic.RelatedInformation +/// Nested message and enum types in `EditFileResult`. +pub mod edit_file_result { + /// aiserver.v1.EditFileResult.FileDiff #[derive(Clone, PartialEq, ::prost::Message)] - pub struct RelatedInformation { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub range: ::core::option::Option, + pub struct FileDiff { + #[prost(message, repeated, tag = "1")] + pub chunks: ::prost::alloc::vec::Vec, + #[prost(enumeration = "file_diff::Editor", tag = "2")] + pub editor: i32, + #[prost(bool, tag = "3")] + pub hit_timeout: bool, } - /// aiserver.v1.Diagnostic.DiagnosticSeverity - #[allow(clippy::enum_variant_names)] + /// Nested message and enum types in `FileDiff`. + pub mod file_diff { + /// aiserver.v1.EditFileResult.FileDiff.ChunkDiff + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ChunkDiff { + #[prost(string, tag = "1")] + pub diff_string: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub old_start: i32, + #[prost(int32, tag = "3")] + pub new_start: i32, + #[prost(int32, tag = "4")] + pub old_lines: i32, + #[prost(int32, tag = "5")] + pub new_lines: i32, + #[prost(int32, tag = "6")] + pub lines_removed: i32, + #[prost(int32, tag = "7")] + pub lines_added: i32, + } + /// aiserver.v1.EditFileResult.FileDiff.Editor + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Editor { + Unspecified = 0, + Ai = 1, + Human = 2, + } + impl Editor { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "EDITOR_UNSPECIFIED", + Self::Ai => "EDITOR_AI", + Self::Human => "EDITOR_HUMAN", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "EDITOR_UNSPECIFIED" => Some(Self::Unspecified), + "EDITOR_AI" => Some(Self::Ai), + "EDITOR_HUMAN" => Some(Self::Human), + _ => None, + } + } + } + } +} +/// aiserver.v1.ToolCallFileSearchResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ToolCallFileSearchResult { + #[prost(message, repeated, tag = "1")] + pub files: ::prost::alloc::vec::Vec, + #[prost(bool, optional, tag = "2")] + pub limit_hit: ::core::option::Option, + #[prost(int32, tag = "3")] + pub num_results: i32, +} +/// Nested message and enum types in `ToolCallFileSearchResult`. +pub mod tool_call_file_search_result { + /// aiserver.v1.ToolCallFileSearchResult.File + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct File { + #[prost(string, tag = "1")] + pub uri: ::prost::alloc::string::String, + } +} +/// aiserver.v1.ListDirResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ListDirResult { + #[prost(message, repeated, tag = "1")] + pub files: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub directory_relative_workspace_path: ::prost::alloc::string::String, +} +/// Nested message and enum types in `ListDirResult`. +pub mod list_dir_result { + /// aiserver.v1.ListDirResult.File + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct File { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub is_directory: bool, + #[prost(int64, optional, tag = "3")] + pub size: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub last_modified: ::core::option::Option<::prost_types::Timestamp>, + #[prost(int32, optional, tag = "5")] + pub num_children: ::core::option::Option, + #[prost(int32, optional, tag = "6")] + pub num_lines: ::core::option::Option, + } +} +/// aiserver.v1.ReadFileResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReadFileResult { + #[prost(string, tag = "1")] + pub contents: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub did_downgrade_to_line_range: bool, + #[prost(bool, tag = "3")] + pub did_shorten_line_range: bool, + #[prost(bool, tag = "4")] + pub did_set_default_line_range: bool, + #[prost(string, optional, tag = "5")] + pub full_file_contents: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag = "6")] + pub outline: ::core::option::Option<::prost::alloc::string::String>, + #[prost(int32, optional, tag = "7")] + pub start_line_one_indexed: ::core::option::Option, + #[prost(int32, optional, tag = "8")] + pub end_line_one_indexed_inclusive: ::core::option::Option, + #[prost(string, tag = "9")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(bool, tag = "10")] + pub did_shorten_char_range: bool, +} +/// aiserver.v1.RipgrepSearchResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RipgrepSearchResult { + #[prost(message, optional, tag = "1")] + pub internal: ::core::option::Option, +} +/// aiserver.v1.RipgrepSearchResultInternal +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RipgrepSearchResultInternal { + #[prost(message, repeated, tag = "1")] + pub results: ::prost::alloc::vec::Vec, + #[prost( + enumeration = "ripgrep_search_result_internal::SearchCompletionExitCode", + optional, + tag = "2" + )] + pub exit: ::core::option::Option, + #[prost(bool, optional, tag = "3")] + pub limit_hit: ::core::option::Option, + #[prost(message, repeated, tag = "4")] + pub messages: ::prost::alloc::vec::Vec< + ripgrep_search_result_internal::ITextSearchCompleteMessage, + >, + #[prost(oneof = "ripgrep_search_result_internal::Stats", tags = "5, 6")] + pub stats: ::core::option::Option, +} +/// Nested message and enum types in `RipgrepSearchResultInternal`. +pub mod ripgrep_search_result_internal { + /// aiserver.v1.RipgrepSearchResultInternal.IFileMatch + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct IFileMatch { + #[prost(string, tag = "1")] + pub resource: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub results: ::prost::alloc::vec::Vec, + } + /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchResult + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ITextSearchResult { + #[prost(oneof = "i_text_search_result::Result", tags = "1, 2")] + pub result: ::core::option::Option, + } + /// Nested message and enum types in `ITextSearchResult`. + pub mod i_text_search_result { + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Result { + #[prost(message, tag = "1")] + Match(super::ITextSearchMatch), + #[prost(message, tag = "2")] + Context(super::ITextSearchContext), + } + } + /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchMatch + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ITextSearchMatch { + #[prost(string, optional, tag = "1")] + pub uri: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "2")] + pub range_locations: ::prost::alloc::vec::Vec, + #[prost(string, tag = "3")] + pub preview_text: ::prost::alloc::string::String, + #[prost(int32, optional, tag = "4")] + pub webview_index: ::core::option::Option, + #[prost(string, optional, tag = "5")] + pub cell_fragment: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchContext + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ITextSearchContext { + #[prost(string, optional, tag = "1")] + pub uri: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag = "2")] + pub text: ::prost::alloc::string::String, + #[prost(int32, tag = "3")] + pub line_number: i32, + } + /// aiserver.v1.RipgrepSearchResultInternal.ISearchRangeSetPairing + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct ISearchRangeSetPairing { + #[prost(message, optional, tag = "1")] + pub source: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub preview: ::core::option::Option, + } + /// aiserver.v1.RipgrepSearchResultInternal.ISearchRange + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct ISearchRange { + #[prost(int32, tag = "1")] + pub start_line_number: i32, + #[prost(int32, tag = "2")] + pub start_column: i32, + #[prost(int32, tag = "3")] + pub end_line_number: i32, + #[prost(int32, tag = "4")] + pub end_column: i32, + } + /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchCompleteMessage + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ITextSearchCompleteMessage { + #[prost(string, tag = "1")] + pub text: ::prost::alloc::string::String, + #[prost(enumeration = "TextSearchCompleteMessageType", tag = "2")] + pub r#type: i32, + #[prost(bool, optional, tag = "3")] + pub trusted: ::core::option::Option, + } + /// aiserver.v1.RipgrepSearchResultInternal.IFileSearchStats + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct IFileSearchStats { + #[prost(bool, tag = "1")] + pub from_cache: bool, + #[prost(int32, tag = "5")] + pub result_count: i32, + #[prost(enumeration = "i_file_search_stats::FileSearchProviderType", tag = "6")] + pub r#type: i32, + #[prost(int32, optional, tag = "7")] + pub sorting_time: ::core::option::Option, + #[prost(oneof = "i_file_search_stats::DetailStats", tags = "2, 3, 4")] + pub detail_stats: ::core::option::Option, + } + /// Nested message and enum types in `IFileSearchStats`. + pub mod i_file_search_stats { + /// aiserver.v1.RipgrepSearchResultInternal.IFileSearchStats.FileSearchProviderType + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum FileSearchProviderType { + Unspecified = 0, + FileSearchProvider = 1, + SearchProcess = 2, + } + impl FileSearchProviderType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "FILE_SEARCH_PROVIDER_TYPE_UNSPECIFIED", + Self::FileSearchProvider => { + "FILE_SEARCH_PROVIDER_TYPE_FILE_SEARCH_PROVIDER" + } + Self::SearchProcess => "FILE_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "FILE_SEARCH_PROVIDER_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "FILE_SEARCH_PROVIDER_TYPE_FILE_SEARCH_PROVIDER" => { + Some(Self::FileSearchProvider) + } + "FILE_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS" => { + Some(Self::SearchProcess) + } + _ => None, + } + } + } + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] + pub enum DetailStats { + #[prost(message, tag = "2")] + SearchEngineStats(super::ISearchEngineStats), + #[prost(message, tag = "3")] + CachedSearchStats(super::ICachedSearchStats), + #[prost(message, tag = "4")] + FileSearchProviderStats(super::IFileSearchProviderStats), + } + } + /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchStats + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct ITextSearchStats { + #[prost(enumeration = "i_text_search_stats::TextSearchProviderType", tag = "1")] + pub r#type: i32, + } + /// Nested message and enum types in `ITextSearchStats`. + pub mod i_text_search_stats { + /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchStats.TextSearchProviderType + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum TextSearchProviderType { + Unspecified = 0, + TextSearchProvider = 1, + SearchProcess = 2, + AiTextSearchProvider = 3, + } + impl TextSearchProviderType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "TEXT_SEARCH_PROVIDER_TYPE_UNSPECIFIED", + Self::TextSearchProvider => { + "TEXT_SEARCH_PROVIDER_TYPE_TEXT_SEARCH_PROVIDER" + } + Self::SearchProcess => "TEXT_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS", + Self::AiTextSearchProvider => { + "TEXT_SEARCH_PROVIDER_TYPE_AI_TEXT_SEARCH_PROVIDER" + } + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "TEXT_SEARCH_PROVIDER_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "TEXT_SEARCH_PROVIDER_TYPE_TEXT_SEARCH_PROVIDER" => { + Some(Self::TextSearchProvider) + } + "TEXT_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS" => { + Some(Self::SearchProcess) + } + "TEXT_SEARCH_PROVIDER_TYPE_AI_TEXT_SEARCH_PROVIDER" => { + Some(Self::AiTextSearchProvider) + } + _ => None, + } + } + } + } + /// aiserver.v1.RipgrepSearchResultInternal.ISearchEngineStats + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct ISearchEngineStats { + #[prost(int32, tag = "1")] + pub file_walk_time: i32, + #[prost(int32, tag = "2")] + pub directories_walked: i32, + #[prost(int32, tag = "3")] + pub files_walked: i32, + #[prost(int32, tag = "4")] + pub cmd_time: i32, + #[prost(int32, optional, tag = "5")] + pub cmd_result_count: ::core::option::Option, + } + /// aiserver.v1.RipgrepSearchResultInternal.ICachedSearchStats + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct ICachedSearchStats { + #[prost(bool, tag = "1")] + pub cache_was_resolved: bool, + #[prost(int32, tag = "2")] + pub cache_lookup_time: i32, + #[prost(int32, tag = "3")] + pub cache_filter_time: i32, + #[prost(int32, tag = "4")] + pub cache_entry_count: i32, + } + /// aiserver.v1.RipgrepSearchResultInternal.IFileSearchProviderStats + #[derive(Clone, Copy, PartialEq, ::prost::Message)] + pub struct IFileSearchProviderStats { + #[prost(int32, tag = "1")] + pub provider_time: i32, + #[prost(int32, tag = "2")] + pub post_process_time: i32, + } + /// aiserver.v1.RipgrepSearchResultInternal.TextSearchCompleteMessageType #[derive( Clone, Copy, @@ -608,86 +1368,1159 @@ pub mod diagnostic { ::prost::Enumeration )] #[repr(i32)] - pub enum DiagnosticSeverity { + pub enum TextSearchCompleteMessageType { Unspecified = 0, - Error = 1, + Information = 1, Warning = 2, - Information = 3, - Hint = 4, } - impl DiagnosticSeverity { + impl TextSearchCompleteMessageType { /// String value of the enum field names used in the ProtoBuf definition. /// /// The values are not transformed in any way and thus are considered stable /// (if the ProtoBuf definition does not change) and safe for programmatic use. pub fn as_str_name(&self) -> &'static str { match self { - Self::Unspecified => "DIAGNOSTIC_SEVERITY_UNSPECIFIED", - Self::Error => "DIAGNOSTIC_SEVERITY_ERROR", - Self::Warning => "DIAGNOSTIC_SEVERITY_WARNING", - Self::Information => "DIAGNOSTIC_SEVERITY_INFORMATION", - Self::Hint => "DIAGNOSTIC_SEVERITY_HINT", + Self::Unspecified => "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_UNSPECIFIED", + Self::Information => "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_INFORMATION", + Self::Warning => "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_WARNING", } } /// Creates an enum from field names used in the ProtoBuf definition. pub fn from_str_name(value: &str) -> ::core::option::Option { match value { - "DIAGNOSTIC_SEVERITY_UNSPECIFIED" => Some(Self::Unspecified), - "DIAGNOSTIC_SEVERITY_ERROR" => Some(Self::Error), - "DIAGNOSTIC_SEVERITY_WARNING" => Some(Self::Warning), - "DIAGNOSTIC_SEVERITY_INFORMATION" => Some(Self::Information), - "DIAGNOSTIC_SEVERITY_HINT" => Some(Self::Hint), + "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_UNSPECIFIED" => { + Some(Self::Unspecified) + } + "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_INFORMATION" => { + Some(Self::Information) + } + "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_WARNING" => Some(Self::Warning), + _ => None, + } + } + } + /// aiserver.v1.RipgrepSearchResultInternal.SearchCompletionExitCode + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum SearchCompletionExitCode { + Unspecified = 0, + Normal = 1, + NewSearchStarted = 2, + } + impl SearchCompletionExitCode { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "SEARCH_COMPLETION_EXIT_CODE_UNSPECIFIED", + Self::Normal => "SEARCH_COMPLETION_EXIT_CODE_NORMAL", + Self::NewSearchStarted => { + "SEARCH_COMPLETION_EXIT_CODE_NEW_SEARCH_STARTED" + } + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "SEARCH_COMPLETION_EXIT_CODE_UNSPECIFIED" => Some(Self::Unspecified), + "SEARCH_COMPLETION_EXIT_CODE_NORMAL" => Some(Self::Normal), + "SEARCH_COMPLETION_EXIT_CODE_NEW_SEARCH_STARTED" => { + Some(Self::NewSearchStarted) + } + _ => None, + } + } + } + #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] + pub enum Stats { + #[prost(message, tag = "5")] + FileSearchStats(IFileSearchStats), + #[prost(message, tag = "6")] + TextSearchStats(ITextSearchStats), + } +} +/// aiserver.v1.MissingFile +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MissingFile { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(enumeration = "missing_file::MissingReason", tag = "2")] + pub missing_reason: i32, + #[prost(int32, optional, tag = "3")] + pub num_lines: ::core::option::Option, +} +/// Nested message and enum types in `MissingFile`. +pub mod missing_file { + /// aiserver.v1.MissingFile.MissingReason + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum MissingReason { + Unspecified = 0, + TooLarge = 1, + NotFound = 2, + } + impl MissingReason { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "MISSING_REASON_UNSPECIFIED", + Self::TooLarge => "MISSING_REASON_TOO_LARGE", + Self::NotFound => "MISSING_REASON_NOT_FOUND", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "MISSING_REASON_UNSPECIFIED" => Some(Self::Unspecified), + "MISSING_REASON_TOO_LARGE" => Some(Self::TooLarge), + "MISSING_REASON_NOT_FOUND" => Some(Self::NotFound), _ => None, } } } } -/// aiserver.v1.DataframeInfo +/// aiserver.v1.ReadSemsearchFilesResult #[derive(Clone, PartialEq, ::prost::Message)] -pub struct DataframeInfo { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub shape: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub data_dimensionality: i32, - #[prost(message, repeated, tag = "6")] - pub columns: ::prost::alloc::vec::Vec, - #[prost(int32, tag = "7")] - pub row_count: i32, - #[prost(string, tag = "8")] - pub index_column: ::prost::alloc::string::String, +pub struct ReadSemsearchFilesResult { + #[prost(message, repeated, tag = "1")] + pub code_results: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "2")] + pub all_files: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "3")] + pub missing_files: ::prost::alloc::vec::Vec, } -/// Nested message and enum types in `DataframeInfo`. -pub mod dataframe_info { - /// aiserver.v1.DataframeInfo.Column - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Column { - #[prost(string, tag = "1")] - pub key: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub r#type: ::prost::alloc::string::String, - } -} -/// aiserver.v1.BM25Chunk +/// aiserver.v1.SemanticSearchFullResult #[derive(Clone, PartialEq, ::prost::Message)] -pub struct Bm25Chunk { - #[prost(string, tag = "1")] - pub content: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub range: ::core::option::Option, - #[prost(int32, tag = "3")] - pub score: i32, - #[prost(string, tag = "4")] - pub relative_path: ::prost::alloc::string::String, +pub struct SemanticSearchFullResult { + #[prost(message, repeated, tag = "1")] + pub code_results: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "2")] + pub all_files: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "3")] + pub missing_files: ::prost::alloc::vec::Vec, } -/// aiserver.v1.SimplestRange +/// aiserver.v1.ReadFileForImportsResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ReadFileForImportsResult { + #[prost(string, tag = "1")] + pub contents: ::prost::alloc::string::String, +} +/// aiserver.v1.CreateFileResult #[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct SimplestRange { +pub struct CreateFileResult { + #[prost(bool, tag = "1")] + pub file_created_successfully: bool, + #[prost(bool, tag = "2")] + pub file_already_exists: bool, +} +/// aiserver.v1.DeleteFileResult +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct DeleteFileResult { + #[prost(bool, tag = "1")] + pub rejected: bool, + #[prost(bool, tag = "2")] + pub file_non_existent: bool, + #[prost(bool, tag = "3")] + pub file_deleted_successfully: bool, +} +/// aiserver.v1.RunTerminalCommandResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RunTerminalCommandResult { + #[prost(string, tag = "1")] + pub output: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub exit_code: i32, + #[prost(bool, optional, tag = "3")] + pub rejected: ::core::option::Option, + #[prost(bool, tag = "4")] + pub popped_out_into_background: bool, +} +/// aiserver.v1.Range +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct Range { #[prost(int32, tag = "1")] pub start_line: i32, #[prost(int32, tag = "2")] - pub end_line_inclusive: i32, + pub start_character: i32, + #[prost(int32, tag = "3")] + pub end_line: i32, + #[prost(int32, tag = "4")] + pub end_character: i32, +} +/// aiserver.v1.MatchRange +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct MatchRange { + #[prost(int32, tag = "1")] + pub start: i32, + #[prost(int32, tag = "2")] + pub end: i32, +} +/// aiserver.v1.ParallelApplyResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ParallelApplyResult { + #[prost(message, repeated, tag = "1")] + pub file_results: ::prost::alloc::vec::Vec, + #[prost(string, optional, tag = "2")] + pub error: ::core::option::Option<::prost::alloc::string::String>, + #[prost(bool, optional, tag = "3")] + pub rejected: ::core::option::Option, +} +/// Nested message and enum types in `ParallelApplyResult`. +pub mod parallel_apply_result { + /// aiserver.v1.ParallelApplyResult.FileResult + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct FileResult { + #[prost(string, tag = "1")] + pub file_path: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub diff: ::core::option::Option, + #[prost(bool, tag = "3")] + pub is_applied: bool, + #[prost(bool, tag = "4")] + pub apply_failed: bool, + #[prost(string, optional, tag = "5")] + pub error: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "6")] + pub linter_errors: ::prost::alloc::vec::Vec, + } +} +/// aiserver.v1.RunTerminalCommandV2Result +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RunTerminalCommandV2Result { + #[prost(string, tag = "1")] + pub output: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub exit_code: i32, + #[prost(bool, optional, tag = "3")] + pub rejected: ::core::option::Option, + #[prost(bool, tag = "4")] + pub popped_out_into_background: bool, + #[prost(bool, tag = "5")] + pub is_running_in_background: bool, + #[prost(bool, tag = "6")] + pub not_interrupted: bool, + #[prost(string, tag = "7")] + pub resulting_working_directory: ::prost::alloc::string::String, + #[prost(bool, tag = "8")] + pub did_user_change: bool, + #[prost(enumeration = "RunTerminalCommandEndedReason", tag = "9")] + pub ended_reason: i32, + #[prost(int32, optional, tag = "10")] + pub exit_code_v2: ::core::option::Option, +} +/// aiserver.v1.WebSearchResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WebSearchResult { + #[prost(message, repeated, tag = "1")] + pub references: ::prost::alloc::vec::Vec, + #[prost(bool, optional, tag = "2")] + pub is_final: ::core::option::Option, + #[prost(bool, optional, tag = "3")] + pub rejected: ::core::option::Option, +} +/// Nested message and enum types in `WebSearchResult`. +pub mod web_search_result { + /// aiserver.v1.WebSearchResult.WebReference + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct WebReference { + #[prost(string, tag = "1")] + pub title: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub url: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub chunk: ::prost::alloc::string::String, + } +} +/// aiserver.v1.WebViewerResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WebViewerResult { + #[prost(string, tag = "1")] + pub url: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub screenshot: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub screenshots: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "4")] + pub console_logs: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `WebViewerResult`. +pub mod web_viewer_result { + /// aiserver.v1.WebViewerResult.ConsoleLog + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ConsoleLog { + #[prost(string, tag = "1")] + pub r#type: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub text: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub source: ::prost::alloc::string::String, + } +} +/// aiserver.v1.MCPResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct McpResult { + #[prost(string, tag = "1")] + pub selected_tool: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub result: ::prost::alloc::string::String, +} +/// aiserver.v1.DiffHistoryResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DiffHistoryResult { + #[prost(message, repeated, tag = "40")] + pub human_changes: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `DiffHistoryResult`. +pub mod diff_history_result { + /// aiserver.v1.DiffHistoryResult.RenderedDiff + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct RenderedDiff { + #[prost(int32, tag = "1")] + pub start_line_number: i32, + #[prost(int32, tag = "2")] + pub end_line_number_exclusive: i32, + #[prost(string, repeated, tag = "3")] + pub before_context_lines: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, + #[prost(string, repeated, tag = "4")] + pub removed_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag = "5")] + pub added_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag = "6")] + pub after_context_lines: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, + } + /// aiserver.v1.DiffHistoryResult.HumanChange + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct HumanChange { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub rendered_diffs: ::prost::alloc::vec::Vec, + } +} +/// aiserver.v1.ImplementerResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ImplementerResult { + #[prost(message, optional, tag = "1")] + pub diff: ::core::option::Option, + #[prost(bool, tag = "2")] + pub is_applied: bool, + #[prost(bool, tag = "3")] + pub apply_failed: bool, + #[prost(message, repeated, tag = "4")] + pub linter_errors: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `ImplementerResult`. +pub mod implementer_result { + /// aiserver.v1.ImplementerResult.FileDiff + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct FileDiff { + #[prost(message, repeated, tag = "1")] + pub chunks: ::prost::alloc::vec::Vec, + #[prost(enumeration = "file_diff::Editor", tag = "2")] + pub editor: i32, + #[prost(bool, tag = "3")] + pub hit_timeout: bool, + } + /// Nested message and enum types in `FileDiff`. + pub mod file_diff { + /// aiserver.v1.ImplementerResult.FileDiff.ChunkDiff + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ChunkDiff { + #[prost(string, tag = "1")] + pub diff_string: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub old_start: i32, + #[prost(int32, tag = "3")] + pub new_start: i32, + #[prost(int32, tag = "4")] + pub old_lines: i32, + #[prost(int32, tag = "5")] + pub new_lines: i32, + #[prost(int32, tag = "6")] + pub lines_removed: i32, + #[prost(int32, tag = "7")] + pub lines_added: i32, + } + /// aiserver.v1.ImplementerResult.FileDiff.Editor + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum Editor { + Unspecified = 0, + Ai = 1, + Human = 2, + } + impl Editor { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "EDITOR_UNSPECIFIED", + Self::Ai => "EDITOR_AI", + Self::Human => "EDITOR_HUMAN", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "EDITOR_UNSPECIFIED" => Some(Self::Unspecified), + "EDITOR_AI" => Some(Self::Ai), + "EDITOR_HUMAN" => Some(Self::Human), + _ => None, + } + } + } + } +} +/// aiserver.v1.SearchSymbolsResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SearchSymbolsResult { + #[prost(message, repeated, tag = "1")] + pub matches: ::prost::alloc::vec::Vec, + #[prost(bool, optional, tag = "2")] + pub rejected: ::core::option::Option, +} +/// Nested message and enum types in `SearchSymbolsResult`. +pub mod search_symbols_result { + /// aiserver.v1.SearchSymbolsResult.SymbolMatch + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct SymbolMatch { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub uri: ::prost::alloc::string::String, + #[prost(message, optional, tag = "3")] + pub range: ::core::option::Option, + #[prost(string, tag = "4")] + pub secondary_text: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "5")] + pub label_matches: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "6")] + pub description_matches: ::prost::alloc::vec::Vec, + #[prost(double, tag = "7")] + pub score: f64, + } +} +/// aiserver.v1.BackgroundComposerFollowupResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct BackgroundComposerFollowupResult { + #[prost(string, tag = "1")] + pub proposed_followup: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub is_sent: bool, +} +/// aiserver.v1.GetLintsForChangeResponse +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetLintsForChangeResponse { + #[prost(message, repeated, tag = "1")] + pub lints: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `GetLintsForChangeResponse`. +pub mod get_lints_for_change_response { + /// aiserver.v1.GetLintsForChangeResponse.Lint + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Lint { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub severity: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(int32, tag = "4")] + pub start_line_number_one_indexed: i32, + #[prost(int32, tag = "5")] + pub start_column_one_indexed: i32, + #[prost(int32, tag = "6")] + pub end_line_number_inclusive_one_indexed: i32, + #[prost(int32, tag = "7")] + pub end_column_one_indexed: i32, + #[prost(message, repeated, tag = "9")] + pub quick_fixes: ::prost::alloc::vec::Vec, + } + /// Nested message and enum types in `Lint`. + pub mod lint { + /// aiserver.v1.GetLintsForChangeResponse.Lint.QuickFix + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct QuickFix { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub kind: ::prost::alloc::string::String, + #[prost(bool, tag = "3")] + pub is_preferred: bool, + #[prost(message, repeated, tag = "4")] + pub edits: ::prost::alloc::vec::Vec, + } + /// Nested message and enum types in `QuickFix`. + pub mod quick_fix { + /// aiserver.v1.GetLintsForChangeResponse.Lint.QuickFix.Edit + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Edit { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub text: ::prost::alloc::string::String, + #[prost(int32, tag = "3")] + pub start_line_number_one_indexed: i32, + #[prost(int32, tag = "4")] + pub start_column_one_indexed: i32, + #[prost(int32, tag = "5")] + pub end_line_number_inclusive_one_indexed: i32, + #[prost(int32, tag = "6")] + pub end_column_one_indexed: i32, + } + } + } +} +/// aiserver.v1.DocumentationChunk +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DocumentationChunk { + #[prost(string, tag = "1")] + pub doc_name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub page_url: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub documentation_chunk: ::prost::alloc::string::String, + #[prost(float, tag = "4")] + pub score: f32, + #[prost(string, tag = "5")] + pub page_title: ::prost::alloc::string::String, +} +/// aiserver.v1.ComposerCapabilityRequest +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ComposerCapabilityRequest { + #[prost( + enumeration = "composer_capability_request::ComposerCapabilityType", + tag = "1" + )] + pub r#type: i32, + #[prost( + oneof = "composer_capability_request::Data", + tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14" + )] + pub data: ::core::option::Option, +} +/// Nested message and enum types in `ComposerCapabilityRequest`. +pub mod composer_capability_request { + /// aiserver.v1.ComposerCapabilityRequest.ToolSchema + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ToolSchema { + #[prost(enumeration = "ToolType", tag = "1")] + pub r#type: i32, + #[prost(string, tag = "2")] + pub name: ::prost::alloc::string::String, + #[prost(map = "string, message", tag = "3")] + pub properties: ::std::collections::HashMap< + ::prost::alloc::string::String, + SchemaProperty, + >, + #[prost(string, repeated, tag = "4")] + pub required: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.SchemaProperty + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct SchemaProperty { + #[prost(string, tag = "1")] + pub r#type: ::prost::alloc::string::String, + #[prost(string, optional, tag = "2")] + pub description: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.LoopOnLintsCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct LoopOnLintsCapability { + #[prost(message, repeated, tag = "1")] + pub linter_errors: ::prost::alloc::vec::Vec, + #[prost(string, optional, tag = "2")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.LoopOnTestsCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct LoopOnTestsCapability { + #[prost(string, repeated, tag = "1")] + pub test_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, optional, tag = "2")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.MegaPlannerCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct MegaPlannerCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.LoopOnCommandCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct LoopOnCommandCapability { + #[prost(string, tag = "1")] + pub command: ::prost::alloc::string::String, + #[prost(string, optional, tag = "2")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, optional, tag = "3")] + pub output: ::core::option::Option<::prost::alloc::string::String>, + #[prost(int32, optional, tag = "4")] + pub exit_code: ::core::option::Option, + } + /// aiserver.v1.ComposerCapabilityRequest.ToolCallCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ToolCallCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "2")] + pub tool_schemas: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag = "3")] + pub relevant_files: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag = "4")] + pub files_in_context: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag = "5")] + pub semantic_search_files: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, + } + /// aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct DiffReviewCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "2")] + pub diffs: ::prost::alloc::vec::Vec, + } + /// Nested message and enum types in `DiffReviewCapability`. + pub mod diff_review_capability { + /// aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability.SimpleFileDiff + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct SimpleFileDiff { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "3")] + pub chunks: ::prost::alloc::vec::Vec, + } + /// Nested message and enum types in `SimpleFileDiff`. + pub mod simple_file_diff { + /// aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability.SimpleFileDiff.Chunk + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Chunk { + #[prost(string, repeated, tag = "1")] + pub old_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag = "2")] + pub new_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(message, optional, tag = "3")] + pub old_range: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub new_range: ::core::option::Option, + } + } + } + /// aiserver.v1.ComposerCapabilityRequest.DecomposerCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct DecomposerCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.ContextPickingCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContextPickingCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, repeated, tag = "2")] + pub potential_context_files: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, + #[prost(message, repeated, tag = "3")] + pub potential_context_code_chunks: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag = "4")] + pub files_in_context: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.EditTrailCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct EditTrailCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.AutoContextCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct AutoContextCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, repeated, tag = "2")] + pub additional_files: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.ContextPlannerCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct ContextPlannerCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "2")] + pub attached_code_chunks: ::prost::alloc::vec::Vec, + } + /// aiserver.v1.ComposerCapabilityRequest.RememberThisCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct RememberThisCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + #[prost(string, tag = "2")] + pub memory: ::prost::alloc::string::String, + } + /// aiserver.v1.ComposerCapabilityRequest.CursorRulesCapability + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct CursorRulesCapability { + #[prost(string, optional, tag = "1")] + pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.ComposerCapabilityRequest.ComposerCapabilityType + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum ComposerCapabilityType { + Unspecified = 0, + LoopOnLints = 1, + LoopOnTests = 2, + MegaPlanner = 3, + LoopOnCommand = 4, + ToolCall = 5, + DiffReview = 6, + ContextPicking = 7, + EditTrail = 8, + AutoContext = 9, + ContextPlanner = 10, + DiffHistory = 11, + RememberThis = 12, + Decomposer = 13, + UsesCodebase = 14, + ToolFormer = 15, + CursorRules = 16, + TokenCounter = 17, + UsageData = 18, + Chimes = 19, + CodeDecayTracker = 20, + BackgroundComposer = 21, + Summarization = 22, + } + impl ComposerCapabilityType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "COMPOSER_CAPABILITY_TYPE_UNSPECIFIED", + Self::LoopOnLints => "COMPOSER_CAPABILITY_TYPE_LOOP_ON_LINTS", + Self::LoopOnTests => "COMPOSER_CAPABILITY_TYPE_LOOP_ON_TESTS", + Self::MegaPlanner => "COMPOSER_CAPABILITY_TYPE_MEGA_PLANNER", + Self::LoopOnCommand => "COMPOSER_CAPABILITY_TYPE_LOOP_ON_COMMAND", + Self::ToolCall => "COMPOSER_CAPABILITY_TYPE_TOOL_CALL", + Self::DiffReview => "COMPOSER_CAPABILITY_TYPE_DIFF_REVIEW", + Self::ContextPicking => "COMPOSER_CAPABILITY_TYPE_CONTEXT_PICKING", + Self::EditTrail => "COMPOSER_CAPABILITY_TYPE_EDIT_TRAIL", + Self::AutoContext => "COMPOSER_CAPABILITY_TYPE_AUTO_CONTEXT", + Self::ContextPlanner => "COMPOSER_CAPABILITY_TYPE_CONTEXT_PLANNER", + Self::DiffHistory => "COMPOSER_CAPABILITY_TYPE_DIFF_HISTORY", + Self::RememberThis => "COMPOSER_CAPABILITY_TYPE_REMEMBER_THIS", + Self::Decomposer => "COMPOSER_CAPABILITY_TYPE_DECOMPOSER", + Self::UsesCodebase => "COMPOSER_CAPABILITY_TYPE_USES_CODEBASE", + Self::ToolFormer => "COMPOSER_CAPABILITY_TYPE_TOOL_FORMER", + Self::CursorRules => "COMPOSER_CAPABILITY_TYPE_CURSOR_RULES", + Self::TokenCounter => "COMPOSER_CAPABILITY_TYPE_TOKEN_COUNTER", + Self::UsageData => "COMPOSER_CAPABILITY_TYPE_USAGE_DATA", + Self::Chimes => "COMPOSER_CAPABILITY_TYPE_CHIMES", + Self::CodeDecayTracker => "COMPOSER_CAPABILITY_TYPE_CODE_DECAY_TRACKER", + Self::BackgroundComposer => { + "COMPOSER_CAPABILITY_TYPE_BACKGROUND_COMPOSER" + } + Self::Summarization => "COMPOSER_CAPABILITY_TYPE_SUMMARIZATION", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "COMPOSER_CAPABILITY_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "COMPOSER_CAPABILITY_TYPE_LOOP_ON_LINTS" => Some(Self::LoopOnLints), + "COMPOSER_CAPABILITY_TYPE_LOOP_ON_TESTS" => Some(Self::LoopOnTests), + "COMPOSER_CAPABILITY_TYPE_MEGA_PLANNER" => Some(Self::MegaPlanner), + "COMPOSER_CAPABILITY_TYPE_LOOP_ON_COMMAND" => Some(Self::LoopOnCommand), + "COMPOSER_CAPABILITY_TYPE_TOOL_CALL" => Some(Self::ToolCall), + "COMPOSER_CAPABILITY_TYPE_DIFF_REVIEW" => Some(Self::DiffReview), + "COMPOSER_CAPABILITY_TYPE_CONTEXT_PICKING" => Some(Self::ContextPicking), + "COMPOSER_CAPABILITY_TYPE_EDIT_TRAIL" => Some(Self::EditTrail), + "COMPOSER_CAPABILITY_TYPE_AUTO_CONTEXT" => Some(Self::AutoContext), + "COMPOSER_CAPABILITY_TYPE_CONTEXT_PLANNER" => Some(Self::ContextPlanner), + "COMPOSER_CAPABILITY_TYPE_DIFF_HISTORY" => Some(Self::DiffHistory), + "COMPOSER_CAPABILITY_TYPE_REMEMBER_THIS" => Some(Self::RememberThis), + "COMPOSER_CAPABILITY_TYPE_DECOMPOSER" => Some(Self::Decomposer), + "COMPOSER_CAPABILITY_TYPE_USES_CODEBASE" => Some(Self::UsesCodebase), + "COMPOSER_CAPABILITY_TYPE_TOOL_FORMER" => Some(Self::ToolFormer), + "COMPOSER_CAPABILITY_TYPE_CURSOR_RULES" => Some(Self::CursorRules), + "COMPOSER_CAPABILITY_TYPE_TOKEN_COUNTER" => Some(Self::TokenCounter), + "COMPOSER_CAPABILITY_TYPE_USAGE_DATA" => Some(Self::UsageData), + "COMPOSER_CAPABILITY_TYPE_CHIMES" => Some(Self::Chimes), + "COMPOSER_CAPABILITY_TYPE_CODE_DECAY_TRACKER" => { + Some(Self::CodeDecayTracker) + } + "COMPOSER_CAPABILITY_TYPE_BACKGROUND_COMPOSER" => { + Some(Self::BackgroundComposer) + } + "COMPOSER_CAPABILITY_TYPE_SUMMARIZATION" => Some(Self::Summarization), + _ => None, + } + } + } + /// aiserver.v1.ComposerCapabilityRequest.ToolType + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum ToolType { + Unspecified = 0, + AddFileToContext = 1, + RunTerminalCommand = 2, + Iterate = 3, + RemoveFileFromContext = 4, + SemanticSearchCodebase = 5, + } + impl ToolType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "TOOL_TYPE_UNSPECIFIED", + Self::AddFileToContext => "TOOL_TYPE_ADD_FILE_TO_CONTEXT", + Self::RunTerminalCommand => "TOOL_TYPE_RUN_TERMINAL_COMMAND", + Self::Iterate => "TOOL_TYPE_ITERATE", + Self::RemoveFileFromContext => "TOOL_TYPE_REMOVE_FILE_FROM_CONTEXT", + Self::SemanticSearchCodebase => "TOOL_TYPE_SEMANTIC_SEARCH_CODEBASE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "TOOL_TYPE_UNSPECIFIED" => Some(Self::Unspecified), + "TOOL_TYPE_ADD_FILE_TO_CONTEXT" => Some(Self::AddFileToContext), + "TOOL_TYPE_RUN_TERMINAL_COMMAND" => Some(Self::RunTerminalCommand), + "TOOL_TYPE_ITERATE" => Some(Self::Iterate), + "TOOL_TYPE_REMOVE_FILE_FROM_CONTEXT" => Some(Self::RemoveFileFromContext), + "TOOL_TYPE_SEMANTIC_SEARCH_CODEBASE" => { + Some(Self::SemanticSearchCodebase) + } + _ => None, + } + } + } + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Data { + #[prost(message, tag = "2")] + LoopOnLints(LoopOnLintsCapability), + #[prost(message, tag = "3")] + LoopOnTests(LoopOnTestsCapability), + #[prost(message, tag = "4")] + MegaPlanner(MegaPlannerCapability), + #[prost(message, tag = "5")] + LoopOnCommand(LoopOnCommandCapability), + #[prost(message, tag = "6")] + ToolCall(ToolCallCapability), + #[prost(message, tag = "7")] + DiffReview(DiffReviewCapability), + #[prost(message, tag = "8")] + ContextPicking(ContextPickingCapability), + #[prost(message, tag = "9")] + EditTrail(EditTrailCapability), + #[prost(message, tag = "10")] + AutoContext(AutoContextCapability), + #[prost(message, tag = "11")] + ContextPlanner(ContextPlannerCapability), + #[prost(message, tag = "12")] + RememberThis(RememberThisCapability), + #[prost(message, tag = "13")] + Decomposer(DecomposerCapability), + #[prost(message, tag = "14")] + CursorRules(CursorRulesCapability), + } +} +/// aiserver.v1.ConversationSummary +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ConversationSummary { + #[prost(string, tag = "1")] + pub summary: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub truncation_last_bubble_id_inclusive: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub client_should_start_sending_from_inclusive_bubble_id: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub previous_conversation_summary_bubble_id: ::prost::alloc::string::String, + #[prost(bool, tag = "5")] + pub includes_tool_results: bool, +} +/// aiserver.v1.DocumentationCitation +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DocumentationCitation { + #[prost(message, repeated, tag = "1")] + pub chunks: ::prost::alloc::vec::Vec, +} +/// aiserver.v1.WebCitation +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WebCitation { + #[prost(message, repeated, tag = "1")] + pub references: ::prost::alloc::vec::Vec, +} +/// aiserver.v1.WebReference +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct WebReference { + #[prost(string, tag = "2")] + pub title: ::prost::alloc::string::String, + #[prost(string, tag = "1")] + pub url: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub chunk: ::prost::alloc::string::String, +} +/// aiserver.v1.DocsReference +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DocsReference { + #[prost(string, tag = "1")] + pub title: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub url: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub chunk: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub name: ::prost::alloc::string::String, +} +/// aiserver.v1.StatusUpdate +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StatusUpdate { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, + #[prost(string, optional, tag = "2")] + pub metadata: ::core::option::Option<::prost::alloc::string::String>, +} +/// aiserver.v1.StatusUpdates +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct StatusUpdates { + #[prost(message, repeated, tag = "1")] + pub updates: ::prost::alloc::vec::Vec, +} +/// aiserver.v1.ComposerFileDiffHistory +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ComposerFileDiffHistory { + #[prost(string, tag = "1")] + pub file_name: ::prost::alloc::string::String, + #[prost(string, repeated, tag = "2")] + pub diff_history: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(double, repeated, tag = "3")] + pub diff_history_timestamps: ::prost::alloc::vec::Vec, +} +/// aiserver.v1.StreamUnifiedChatRequest +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct StreamUnifiedChatRequest {} +/// Nested message and enum types in `StreamUnifiedChatRequest`. +pub mod stream_unified_chat_request { + /// aiserver.v1.StreamUnifiedChatRequest.UnifiedMode + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum UnifiedMode { + Unspecified = 0, + Chat = 1, + Agent = 2, + Edit = 3, + Custom = 4, + } + impl UnifiedMode { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "UNIFIED_MODE_UNSPECIFIED", + Self::Chat => "UNIFIED_MODE_CHAT", + Self::Agent => "UNIFIED_MODE_AGENT", + Self::Edit => "UNIFIED_MODE_EDIT", + Self::Custom => "UNIFIED_MODE_CUSTOM", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "UNIFIED_MODE_UNSPECIFIED" => Some(Self::Unspecified), + "UNIFIED_MODE_CHAT" => Some(Self::Chat), + "UNIFIED_MODE_AGENT" => Some(Self::Agent), + "UNIFIED_MODE_EDIT" => Some(Self::Edit), + "UNIFIED_MODE_CUSTOM" => Some(Self::Custom), + _ => None, + } + } + } +} +/// aiserver.v1.ContextPiece +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ContextPiece { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub content: ::prost::alloc::string::String, + #[prost(float, tag = "3")] + pub score: f32, +} +/// aiserver.v1.ServiceStatusUpdate +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ServiceStatusUpdate { + #[prost(string, tag = "1")] + pub message: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub codicon: ::prost::alloc::string::String, + #[prost(bool, optional, tag = "3")] + pub allow_command_links_potentially_unsafe_please_only_use_for_handwritten_trusted_markdown: ::core::option::Option< + bool, + >, + #[prost(string, optional, tag = "4")] + pub action_to_run_on_status_update: ::core::option::Option< + ::prost::alloc::string::String, + >, +} +/// aiserver.v1.SymbolLink +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SymbolLink { + #[prost(string, tag = "1")] + pub symbol_name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub symbol_search_string: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(int32, tag = "4")] + pub rough_line_number: i32, +} +/// aiserver.v1.FileLink +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FileLink { + #[prost(string, tag = "1")] + pub display_name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub relative_workspace_path: ::prost::alloc::string::String, +} +/// aiserver.v1.RedDiff +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct RedDiff { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub red_ranges: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "3")] + pub red_ranges_reversed: ::prost::alloc::vec::Vec, + #[prost(string, tag = "4")] + pub start_hash: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub end_hash: ::prost::alloc::string::String, +} +/// aiserver.v1.DiffFile +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DiffFile { + #[prost(string, tag = "1")] + pub file_details: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub file_name: ::prost::alloc::string::String, +} +/// aiserver.v1.ViewableCommitProps +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ViewableCommitProps { + #[prost(string, tag = "1")] + pub description: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub message: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "3")] + pub files: ::prost::alloc::vec::Vec, +} +/// aiserver.v1.ViewablePRProps +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ViewablePrProps { + #[prost(string, tag = "1")] + pub title: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub body: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "3")] + pub files: ::prost::alloc::vec::Vec, +} +/// aiserver.v1.ViewableDiffProps +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ViewableDiffProps { + #[prost(message, repeated, tag = "1")] + pub files: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub diff_preface: ::prost::alloc::string::String, +} +/// aiserver.v1.ViewableGitContext +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ViewableGitContext { + #[prost(message, optional, tag = "1")] + pub commit_data: ::core::option::Option, + #[prost(message, optional, tag = "2")] + pub pull_request_data: ::core::option::Option, + #[prost(message, repeated, tag = "3")] + pub diff_data: ::prost::alloc::vec::Vec, } /// aiserver.v1.ConversationMessage #[derive(Clone, PartialEq, ::prost::Message)] @@ -790,6 +2623,30 @@ pub struct ConversationMessage { >, #[prost(message, repeated, tag = "43")] pub cursor_rules: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "44")] + pub context_pieces: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "45")] + pub thinking: ::core::option::Option, + #[prost(message, repeated, tag = "46")] + pub all_thinking_blocks: ::prost::alloc::vec::Vec, + #[prost( + enumeration = "stream_unified_chat_request::UnifiedMode", + optional, + tag = "47" + )] + pub unified_mode: ::core::option::Option, + #[prost(message, repeated, tag = "48")] + pub diffs_since_last_apply: ::prost::alloc::vec::Vec< + conversation_message::DiffSinceLastApply, + >, + #[prost(message, repeated, tag = "49")] + pub deleted_files: ::prost::alloc::vec::Vec, + #[prost(string, optional, tag = "50")] + pub usage_uuid: ::core::option::Option<::prost::alloc::string::String>, + #[prost(enumeration = "ClientSideToolV2", repeated, tag = "51")] + pub supported_tools: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "52")] + pub current_file_location_data: ::core::option::Option, } /// Nested message and enum types in `ConversationMessage`. pub mod conversation_message { @@ -818,7 +2675,6 @@ pub mod conversation_message { /// Nested message and enum types in `CodeChunk`. pub mod code_chunk { /// aiserver.v1.ConversationMessage.CodeChunk.Intent - #[allow(clippy::enum_variant_names)] #[derive( Clone, Copy, @@ -873,7 +2729,6 @@ pub mod conversation_message { } } /// aiserver.v1.ConversationMessage.CodeChunk.SummarizationStrategy - #[allow(clippy::enum_variant_names)] #[derive( Clone, Copy, @@ -1073,8 +2928,37 @@ pub mod conversation_message { #[prost(message, repeated, tag = "2")] pub rendered_diffs: ::prost::alloc::vec::Vec, } + /// aiserver.v1.ConversationMessage.Thinking + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Thinking { + #[prost(string, tag = "1")] + pub text: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub signature: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub redacted_thinking: ::prost::alloc::string::String, + } + /// aiserver.v1.ConversationMessage.DiffSinceLastApply + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct DiffSinceLastApply { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub diff: ::core::option::Option, + #[prost(bool, optional, tag = "4")] + pub is_accepted: ::core::option::Option, + #[prost(bool, optional, tag = "5")] + pub is_rejected: ::core::option::Option, + #[prost(int32, optional, tag = "6")] + pub last_apply_chained_from_n_human_messages_ago: ::core::option::Option, + } + /// aiserver.v1.ConversationMessage.DeletedFile + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct DeletedFile { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + } /// aiserver.v1.ConversationMessage.MessageType - #[allow(clippy::enum_variant_names)] #[derive( Clone, Copy, @@ -1115,61 +2999,98 @@ pub mod conversation_message { } } } -/// aiserver.v1.WebReference +/// aiserver.v1.CurrentFileLocationData #[derive(Clone, PartialEq, ::prost::Message)] -pub struct WebReference { - #[prost(string, tag = "2")] - pub title: ::prost::alloc::string::String, +pub struct CurrentFileLocationData { #[prost(string, tag = "1")] - pub url: ::prost::alloc::string::String, + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub line_number: i32, #[prost(string, tag = "3")] - pub chunk: ::prost::alloc::string::String, + pub text: ::prost::alloc::string::String, } -/// aiserver.v1.ViewableGitContext +/// aiserver.v1.FolderInfo #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ViewableGitContext { - #[prost(message, optional, tag = "1")] - pub commit_data: ::core::option::Option, - #[prost(message, optional, tag = "2")] - pub pull_request_data: ::core::option::Option, +pub struct FolderInfo { + #[prost(string, tag = "1")] + pub relative_path: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub files: ::prost::alloc::vec::Vec, +} +/// aiserver.v1.FolderFileInfo +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FolderFileInfo { + #[prost(string, tag = "1")] + pub relative_path: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub content: ::prost::alloc::string::String, + #[prost(bool, tag = "3")] + pub truncated: bool, + #[prost(float, tag = "4")] + pub score: f32, +} +/// aiserver.v1.InterpreterResult +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct InterpreterResult { + #[prost(string, tag = "1")] + pub output: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub success: bool, +} +/// aiserver.v1.SimpleFileDiff +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SimpleFileDiff { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, #[prost(message, repeated, tag = "3")] - pub diff_data: ::prost::alloc::vec::Vec, + pub chunks: ::prost::alloc::vec::Vec, } -/// aiserver.v1.ViewablePRProps +/// Nested message and enum types in `SimpleFileDiff`. +pub mod simple_file_diff { + /// aiserver.v1.SimpleFileDiff.Chunk + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Chunk { + #[prost(string, repeated, tag = "1")] + pub old_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag = "2")] + pub new_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(message, optional, tag = "3")] + pub old_range: ::core::option::Option, + #[prost(message, optional, tag = "4")] + pub new_range: ::core::option::Option, + } +} +/// aiserver.v1.Commit #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ViewablePrProps { +pub struct Commit { + #[prost(string, tag = "1")] + pub sha: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub message: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub description: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "4")] + pub diff: ::prost::alloc::vec::Vec, + #[prost(string, tag = "5")] + pub author: ::prost::alloc::string::String, + #[prost(string, tag = "6")] + pub date: ::prost::alloc::string::String, +} +/// aiserver.v1.PullRequest +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PullRequest { #[prost(string, tag = "1")] pub title: ::prost::alloc::string::String, #[prost(string, tag = "2")] pub body: ::prost::alloc::string::String, #[prost(message, repeated, tag = "3")] - pub files: ::prost::alloc::vec::Vec, + pub diff: ::prost::alloc::vec::Vec, } -/// aiserver.v1.DiffFile +/// aiserver.v1.SuggestedCodeBlock #[derive(Clone, PartialEq, ::prost::Message)] -pub struct DiffFile { +pub struct SuggestedCodeBlock { #[prost(string, tag = "1")] - pub file_details: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub file_name: ::prost::alloc::string::String, -} -/// aiserver.v1.ViewableDiffProps -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ViewableDiffProps { - #[prost(message, repeated, tag = "1")] - pub files: ::prost::alloc::vec::Vec, - #[prost(string, tag = "2")] - pub diff_preface: ::prost::alloc::string::String, -} -/// aiserver.v1.ViewableCommitProps -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ViewableCommitProps { - #[prost(string, tag = "1")] - pub description: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub message: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "3")] - pub files: ::prost::alloc::vec::Vec, + pub relative_workspace_path: ::prost::alloc::string::String, } /// aiserver.v1.UserResponseToSuggestedCodeBlock #[derive(Clone, PartialEq, ::prost::Message)] @@ -1187,7 +3108,6 @@ pub struct UserResponseToSuggestedCodeBlock { /// Nested message and enum types in `UserResponseToSuggestedCodeBlock`. pub mod user_response_to_suggested_code_block { /// aiserver.v1.UserResponseToSuggestedCodeBlock.UserResponseType - #[allow(clippy::enum_variant_names)] #[derive( Clone, Copy, @@ -1231,1013 +3151,6 @@ pub mod user_response_to_suggested_code_block { } } } -/// aiserver.v1.FileDiff -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FileDiff { - #[prost(string, tag = "1")] - pub from: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub to: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "3")] - pub chunks: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `FileDiff`. -pub mod file_diff { - /// aiserver.v1.FileDiff.Chunk - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Chunk { - #[prost(string, tag = "1")] - pub content: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "2")] - pub lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(int32, tag = "3")] - pub old_start: i32, - #[prost(int32, tag = "4")] - pub old_lines: i32, - #[prost(int32, tag = "5")] - pub new_start: i32, - #[prost(int32, tag = "6")] - pub new_lines: i32, - } -} -/// aiserver.v1.ToolResultError -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ToolResultError { - #[prost(string, tag = "1")] - pub client_visible_error_message: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub model_visible_error_message: ::prost::alloc::string::String, - #[prost(string, optional, tag = "3")] - pub actual_error_message_only_send_from_client_to_server_never_the_other_way_around_because_that_may_be_a_security_risk: ::core::option::Option< - ::prost::alloc::string::String, - >, -} -/// aiserver.v1.ToolResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ToolResult { - #[prost(oneof = "tool_result::ToolResult", tags = "1, 2, 3")] - pub tool_result: ::core::option::Option, -} -/// Nested message and enum types in `ToolResult`. -pub mod tool_result { - #[allow(clippy::enum_variant_names)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum ToolResult { - #[prost(message, tag = "1")] - BuiltinToolResult(super::BuiltinToolResult), - #[prost(message, tag = "2")] - CustomToolResult(super::CustomToolResult), - #[prost(message, tag = "3")] - ErrorToolResult(super::ErrorToolResult), - } -} -/// aiserver.v1.ErrorToolResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ErrorToolResult { - #[prost(string, tag = "1")] - pub error_message: ::prost::alloc::string::String, -} -/// aiserver.v1.CustomToolResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CustomToolResult { - #[prost(string, tag = "1")] - pub tool_id: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub result: ::prost::alloc::string::String, -} -/// aiserver.v1.BuiltinToolResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct BuiltinToolResult { - #[prost(enumeration = "BuiltinTool", tag = "1")] - pub tool: i32, - #[prost( - oneof = "builtin_tool_result::Result", - tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24" - )] - pub result: ::core::option::Option, -} -/// Nested message and enum types in `BuiltinToolResult`. -pub mod builtin_tool_result { - #[allow(clippy::enum_variant_names)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Result { - #[prost(message, tag = "2")] - SearchResult(super::SearchResult), - #[prost(message, tag = "3")] - ReadChunkResult(super::ReadChunkResult), - #[prost(message, tag = "4")] - GotodefResult(super::GotodefResult), - #[prost(message, tag = "5")] - EditResult(super::EditResult), - #[prost(message, tag = "6")] - UndoEditResult(super::UndoEditResult), - #[prost(message, tag = "7")] - EndResult(super::EndResult), - #[prost(message, tag = "8")] - NewFileResult(super::NewFileResult), - #[prost(message, tag = "9")] - AddTestResult(super::AddTestResult), - #[prost(message, tag = "10")] - RunTestResult(super::RunTestResult), - #[prost(message, tag = "11")] - DeleteTestResult(super::DeleteTestResult), - #[prost(message, tag = "12")] - SaveFileResult(super::SaveFileResult), - #[prost(message, tag = "13")] - GetTestsResult(super::GetTestsResult), - #[prost(message, tag = "14")] - GetSymbolsResult(super::GetSymbolsResult), - #[prost(message, tag = "15")] - SemanticSearchResult(super::SemanticSearchResult), - #[prost(message, tag = "16")] - GetProjectStructureResult(super::GetProjectStructureResult), - #[prost(message, tag = "17")] - CreateRmFilesResult(super::CreateRmFilesResult), - #[prost(message, tag = "18")] - RunTerminalCommandsResult(super::RunTerminalCommandsResult), - #[prost(message, tag = "19")] - NewEditResult(super::NewEditResult), - #[prost(message, tag = "20")] - ReadWithLinterResult(super::ReadWithLinterResult), - #[prost(message, tag = "21")] - AddUiStepResult(super::AddUiStepResult), - #[prost(message, tag = "22")] - ReadSemsearchFilesResult(super::ReadSemsearchFilesResult), - #[prost(message, tag = "23")] - CreateFileResult(super::CreateFileResult), - #[prost(message, tag = "24")] - DeleteFileResult(super::DeleteFileResult), - } -} -/// aiserver.v1.UndoEditResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UndoEditResult { - #[prost(string, repeated, tag = "1")] - pub feedback: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, tag = "4")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub context_start_line_number: i32, - #[prost(string, repeated, tag = "3")] - pub context_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(int32, tag = "5")] - pub context_total_num_lines: i32, - #[prost(int32, tag = "6")] - pub file_total_lines: i32, -} -/// aiserver.v1.SemanticSearchResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SemanticSearchResult { - #[prost(message, repeated, tag = "1")] - pub results: ::prost::alloc::vec::Vec, - #[prost(map = "string, string", tag = "2")] - pub files: ::std::collections::HashMap< - ::prost::alloc::string::String, - ::prost::alloc::string::String, - >, -} -/// Nested message and enum types in `SemanticSearchResult`. -pub mod semantic_search_result { - /// aiserver.v1.SemanticSearchResult.Item - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Item { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(float, tag = "2")] - pub score: f32, - #[prost(string, tag = "3")] - pub content: ::prost::alloc::string::String, - #[prost(message, optional, tag = "4")] - pub range: ::core::option::Option, - #[prost(string, optional, tag = "5")] - pub original_content: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "6")] - pub detailed_lines: ::prost::alloc::vec::Vec, - } -} -/// aiserver.v1.SimpleRange -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct SimpleRange { - #[prost(int32, tag = "1")] - pub start_line_number: i32, - #[prost(int32, tag = "2")] - pub start_column: i32, - #[prost(int32, tag = "3")] - pub end_line_number_inclusive: i32, - #[prost(int32, tag = "4")] - pub end_column: i32, -} -/// aiserver.v1.SearchResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SearchResult { - #[prost(message, repeated, tag = "1")] - pub file_results: ::prost::alloc::vec::Vec, - #[prost(int32, tag = "2")] - pub num_total_matches: i32, - #[prost(int32, tag = "3")] - pub num_total_matched_files: i32, - #[prost(bool, tag = "4")] - pub num_total_may_be_incomplete: bool, - #[prost(bool, tag = "5")] - pub files_only: bool, -} -/// aiserver.v1.SearchToolFileSearchResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SearchToolFileSearchResult { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub num_matches: i32, - #[prost(message, repeated, tag = "3")] - pub potentially_relevant_lines: ::prost::alloc::vec::Vec< - search_tool_file_search_result::Line, - >, - #[prost(bool, tag = "4")] - pub cropped: bool, -} -/// Nested message and enum types in `SearchToolFileSearchResult`. -pub mod search_tool_file_search_result { - /// aiserver.v1.SearchToolFileSearchResult.Line - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Line { - #[prost(int32, tag = "1")] - pub line_number: i32, - #[prost(string, tag = "2")] - pub text: ::prost::alloc::string::String, - } -} -/// aiserver.v1.SaveFileResult -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct SaveFileResult {} -/// aiserver.v1.RunTestResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RunTestResult { - #[prost(string, tag = "1")] - pub result: ::prost::alloc::string::String, -} -/// aiserver.v1.RunTerminalCommandsResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RunTerminalCommandsResult { - #[prost(string, repeated, tag = "1")] - pub outputs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -/// aiserver.v1.ReadWithLinterResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ReadWithLinterResult { - #[prost(string, tag = "1")] - pub contents: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub diagnostics: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.ReadSemsearchFilesResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ReadSemsearchFilesResult { - #[prost(message, repeated, tag = "1")] - pub code_results: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "2")] - pub all_files: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "3")] - pub missing_files: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.MissingFile -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct MissingFile { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(enumeration = "missing_file::MissingReason", tag = "2")] - pub missing_reason: i32, - #[prost(int32, optional, tag = "3")] - pub num_lines: ::core::option::Option, -} -/// Nested message and enum types in `MissingFile`. -pub mod missing_file { - /// aiserver.v1.MissingFile.MissingReason - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum MissingReason { - Unspecified = 0, - TooLarge = 1, - NotFound = 2, - } - impl MissingReason { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "MISSING_REASON_UNSPECIFIED", - Self::TooLarge => "MISSING_REASON_TOO_LARGE", - Self::NotFound => "MISSING_REASON_NOT_FOUND", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "MISSING_REASON_UNSPECIFIED" => Some(Self::Unspecified), - "MISSING_REASON_TOO_LARGE" => Some(Self::TooLarge), - "MISSING_REASON_NOT_FOUND" => Some(Self::NotFound), - _ => None, - } - } - } -} -/// aiserver.v1.File -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct File { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub contents: ::prost::alloc::string::String, -} -/// aiserver.v1.CodeResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CodeResult { - #[prost(message, optional, tag = "1")] - pub code_block: ::core::option::Option, - #[prost(float, tag = "2")] - pub score: f32, -} -/// aiserver.v1.ReadChunkResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ReadChunkResult { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub start_line_number: i32, - #[prost(string, repeated, tag = "3")] - pub lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(int32, tag = "4")] - pub total_num_lines: i32, - #[prost(bool, tag = "5")] - pub cropped: bool, -} -/// aiserver.v1.NewFileResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct NewFileResult { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub file_total_lines: i32, -} -/// aiserver.v1.NewEditResult -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct NewEditResult {} -/// aiserver.v1.GotodefResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GotodefResult { - #[prost(message, repeated, tag = "1")] - pub results: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.GotodefToolFileSearchResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GotodefToolFileSearchResult { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "3")] - pub potentially_relevant_lines: ::prost::alloc::vec::Vec< - gotodef_tool_file_search_result::Line, - >, -} -/// Nested message and enum types in `GotodefToolFileSearchResult`. -pub mod gotodef_tool_file_search_result { - /// aiserver.v1.GotodefToolFileSearchResult.Line - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Line { - #[prost(int32, tag = "1")] - pub line_number: i32, - #[prost(string, tag = "2")] - pub text: ::prost::alloc::string::String, - } -} -/// aiserver.v1.GetTestsResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetTestsResult { - #[prost(message, repeated, tag = "1")] - pub tests: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `GetTestsResult`. -pub mod get_tests_result { - /// aiserver.v1.GetTestsResult.Test - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Test { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "2")] - pub lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - } -} -/// aiserver.v1.GetSymbolsResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetSymbolsResult { - #[prost(message, repeated, tag = "1")] - pub symbols: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.DocumentSymbol -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DocumentSymbol { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub detail: ::prost::alloc::string::String, - #[prost(enumeration = "document_symbol::SymbolKind", tag = "3")] - pub kind: i32, - #[prost(string, tag = "5")] - pub container_name: ::prost::alloc::string::String, - #[prost(message, optional, tag = "6")] - pub range: ::core::option::Option, - #[prost(message, optional, tag = "7")] - pub selection_range: ::core::option::Option, - #[prost(message, repeated, tag = "8")] - pub children: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `DocumentSymbol`. -pub mod document_symbol { - /// aiserver.v1.DocumentSymbol.Range - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct Range { - #[prost(int32, tag = "1")] - pub start_line_number: i32, - #[prost(int32, tag = "2")] - pub start_column: i32, - #[prost(int32, tag = "3")] - pub end_line_number: i32, - #[prost(int32, tag = "4")] - pub end_column: i32, - } - /// aiserver.v1.DocumentSymbol.SymbolKind - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum SymbolKind { - Unspecified = 0, - File = 1, - Module = 2, - Namespace = 3, - Package = 4, - Class = 5, - Method = 6, - Property = 7, - Field = 8, - Constructor = 9, - Enum = 10, - Interface = 11, - Function = 12, - Variable = 13, - Constant = 14, - String = 15, - Number = 16, - Boolean = 17, - Array = 18, - Object = 19, - Key = 20, - Null = 21, - EnumMember = 22, - Struct = 23, - Event = 24, - Operator = 25, - TypeParameter = 26, - } - impl SymbolKind { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "SYMBOL_KIND_UNSPECIFIED", - Self::File => "SYMBOL_KIND_FILE", - Self::Module => "SYMBOL_KIND_MODULE", - Self::Namespace => "SYMBOL_KIND_NAMESPACE", - Self::Package => "SYMBOL_KIND_PACKAGE", - Self::Class => "SYMBOL_KIND_CLASS", - Self::Method => "SYMBOL_KIND_METHOD", - Self::Property => "SYMBOL_KIND_PROPERTY", - Self::Field => "SYMBOL_KIND_FIELD", - Self::Constructor => "SYMBOL_KIND_CONSTRUCTOR", - Self::Enum => "SYMBOL_KIND_ENUM", - Self::Interface => "SYMBOL_KIND_INTERFACE", - Self::Function => "SYMBOL_KIND_FUNCTION", - Self::Variable => "SYMBOL_KIND_VARIABLE", - Self::Constant => "SYMBOL_KIND_CONSTANT", - Self::String => "SYMBOL_KIND_STRING", - Self::Number => "SYMBOL_KIND_NUMBER", - Self::Boolean => "SYMBOL_KIND_BOOLEAN", - Self::Array => "SYMBOL_KIND_ARRAY", - Self::Object => "SYMBOL_KIND_OBJECT", - Self::Key => "SYMBOL_KIND_KEY", - Self::Null => "SYMBOL_KIND_NULL", - Self::EnumMember => "SYMBOL_KIND_ENUM_MEMBER", - Self::Struct => "SYMBOL_KIND_STRUCT", - Self::Event => "SYMBOL_KIND_EVENT", - Self::Operator => "SYMBOL_KIND_OPERATOR", - Self::TypeParameter => "SYMBOL_KIND_TYPE_PARAMETER", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "SYMBOL_KIND_UNSPECIFIED" => Some(Self::Unspecified), - "SYMBOL_KIND_FILE" => Some(Self::File), - "SYMBOL_KIND_MODULE" => Some(Self::Module), - "SYMBOL_KIND_NAMESPACE" => Some(Self::Namespace), - "SYMBOL_KIND_PACKAGE" => Some(Self::Package), - "SYMBOL_KIND_CLASS" => Some(Self::Class), - "SYMBOL_KIND_METHOD" => Some(Self::Method), - "SYMBOL_KIND_PROPERTY" => Some(Self::Property), - "SYMBOL_KIND_FIELD" => Some(Self::Field), - "SYMBOL_KIND_CONSTRUCTOR" => Some(Self::Constructor), - "SYMBOL_KIND_ENUM" => Some(Self::Enum), - "SYMBOL_KIND_INTERFACE" => Some(Self::Interface), - "SYMBOL_KIND_FUNCTION" => Some(Self::Function), - "SYMBOL_KIND_VARIABLE" => Some(Self::Variable), - "SYMBOL_KIND_CONSTANT" => Some(Self::Constant), - "SYMBOL_KIND_STRING" => Some(Self::String), - "SYMBOL_KIND_NUMBER" => Some(Self::Number), - "SYMBOL_KIND_BOOLEAN" => Some(Self::Boolean), - "SYMBOL_KIND_ARRAY" => Some(Self::Array), - "SYMBOL_KIND_OBJECT" => Some(Self::Object), - "SYMBOL_KIND_KEY" => Some(Self::Key), - "SYMBOL_KIND_NULL" => Some(Self::Null), - "SYMBOL_KIND_ENUM_MEMBER" => Some(Self::EnumMember), - "SYMBOL_KIND_STRUCT" => Some(Self::Struct), - "SYMBOL_KIND_EVENT" => Some(Self::Event), - "SYMBOL_KIND_OPERATOR" => Some(Self::Operator), - "SYMBOL_KIND_TYPE_PARAMETER" => Some(Self::TypeParameter), - _ => None, - } - } - } -} -/// aiserver.v1.GetProjectStructureResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetProjectStructureResult { - #[prost(message, repeated, tag = "1")] - pub files: ::prost::alloc::vec::Vec, - #[prost(string, tag = "2")] - pub root_workspace_path: ::prost::alloc::string::String, -} -/// Nested message and enum types in `GetProjectStructureResult`. -pub mod get_project_structure_result { - /// aiserver.v1.GetProjectStructureResult.File - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct File { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub outline: ::prost::alloc::string::String, - } -} -/// aiserver.v1.EndResult -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct EndResult {} -/// aiserver.v1.EditResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct EditResult { - #[prost(string, repeated, tag = "1")] - pub feedback: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(int32, tag = "2")] - pub context_start_line_number: i32, - #[prost(string, repeated, tag = "3")] - pub context_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, tag = "4")] - pub file: ::prost::alloc::string::String, - #[prost(int32, tag = "5")] - pub file_total_lines: i32, - #[prost(message, repeated, tag = "6")] - pub structured_feedback: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `EditResult`. -pub mod edit_result { - /// aiserver.v1.EditResult.RelatedInformation - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct RelatedInformation { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub start_line_number: i32, - #[prost(int32, tag = "3")] - pub end_line_number: i32, - #[prost(string, tag = "4")] - pub relative_workspace_path: ::prost::alloc::string::String, - } - /// aiserver.v1.EditResult.Feedback - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Feedback { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub severity: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub start_line_number: i32, - #[prost(int32, tag = "4")] - pub end_line_number: i32, - #[prost(message, repeated, tag = "5")] - pub related_information: ::prost::alloc::vec::Vec, - } -} -/// aiserver.v1.DeleteTestResult -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct DeleteTestResult {} -/// aiserver.v1.DeleteFileResult -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct DeleteFileResult { - #[prost(bool, tag = "1")] - pub rejected: bool, - #[prost(bool, tag = "2")] - pub file_non_existent: bool, - #[prost(bool, tag = "3")] - pub file_deleted_successfully: bool, -} -/// aiserver.v1.CreateRmFilesResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CreateRmFilesResult { - #[prost(string, repeated, tag = "1")] - pub created_file_paths: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "2")] - pub removed_file_paths: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -/// aiserver.v1.CreateFileResult -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct CreateFileResult { - #[prost(bool, tag = "1")] - pub file_created_successfully: bool, - #[prost(bool, tag = "2")] - pub file_already_exists: bool, -} -/// aiserver.v1.AddUiStepResult -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct AddUiStepResult {} -/// aiserver.v1.AddTestResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct AddTestResult { - #[prost(message, repeated, tag = "1")] - pub feedback: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `AddTestResult`. -pub mod add_test_result { - /// aiserver.v1.AddTestResult.RelatedInformation - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct RelatedInformation { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub start_line_number: i32, - #[prost(int32, tag = "3")] - pub end_line_number: i32, - #[prost(string, tag = "4")] - pub relative_workspace_path: ::prost::alloc::string::String, - } - /// aiserver.v1.AddTestResult.Feedback - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Feedback { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub severity: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub start_line_number: i32, - #[prost(int32, tag = "4")] - pub end_line_number: i32, - #[prost(message, repeated, tag = "5")] - pub related_information: ::prost::alloc::vec::Vec, - } -} -/// aiserver.v1.SuggestedCodeBlock -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SuggestedCodeBlock { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, -} -/// aiserver.v1.SimpleFileDiff -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SimpleFileDiff { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "3")] - pub chunks: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `SimpleFileDiff`. -pub mod simple_file_diff { - /// aiserver.v1.SimpleFileDiff.Chunk - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Chunk { - #[prost(string, repeated, tag = "1")] - pub old_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "2")] - pub new_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(message, optional, tag = "3")] - pub old_range: ::core::option::Option, - #[prost(message, optional, tag = "4")] - pub new_range: ::core::option::Option, - } -} -/// aiserver.v1.LineRange -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct LineRange { - #[prost(int32, tag = "1")] - pub start_line_number: i32, - #[prost(int32, tag = "2")] - pub end_line_number_inclusive: i32, -} -/// aiserver.v1.RedDiff -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RedDiff { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub red_ranges: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "3")] - pub red_ranges_reversed: ::prost::alloc::vec::Vec, - #[prost(string, tag = "4")] - pub start_hash: ::prost::alloc::string::String, - #[prost(string, tag = "5")] - pub end_hash: ::prost::alloc::string::String, -} -/// aiserver.v1.PullRequest -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PullRequest { - #[prost(string, tag = "1")] - pub title: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub body: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "3")] - pub diff: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.ListDirResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListDirResult { - #[prost(message, repeated, tag = "1")] - pub files: ::prost::alloc::vec::Vec, - #[prost(string, tag = "2")] - pub directory_relative_workspace_path: ::prost::alloc::string::String, -} -/// Nested message and enum types in `ListDirResult`. -pub mod list_dir_result { - /// aiserver.v1.ListDirResult.File - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct File { - #[prost(string, tag = "1")] - pub name: ::prost::alloc::string::String, - #[prost(bool, tag = "2")] - pub is_directory: bool, - #[prost(int64, optional, tag = "3")] - pub size: ::core::option::Option, - #[prost(message, optional, tag = "4")] - pub last_modified: ::core::option::Option<::prost_types::Timestamp>, - #[prost(int32, optional, tag = "5")] - pub num_children: ::core::option::Option, - #[prost(int32, optional, tag = "6")] - pub num_lines: ::core::option::Option, - } -} -/// aiserver.v1.LinterErrorsWithoutFileContents -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LinterErrorsWithoutFileContents { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub errors: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.InterpreterResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct InterpreterResult { - #[prost(string, tag = "1")] - pub output: ::prost::alloc::string::String, - #[prost(bool, tag = "2")] - pub success: bool, -} -/// aiserver.v1.ImageProto -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ImageProto { - #[prost(bytes = "vec", tag = "1")] - pub data: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "2")] - pub dimension: ::core::option::Option, -} -/// Nested message and enum types in `ImageProto`. -pub mod image_proto { - /// aiserver.v1.ImageProto.Dimension - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct Dimension { - #[prost(int32, tag = "1")] - pub width: i32, - #[prost(int32, tag = "2")] - pub height: i32, - } -} -/// aiserver.v1.GitDiff -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GitDiff { - #[prost(message, repeated, tag = "1")] - pub diffs: ::prost::alloc::vec::Vec, - #[prost(enumeration = "git_diff::DiffType", tag = "2")] - pub diff_type: i32, -} -/// Nested message and enum types in `GitDiff`. -pub mod git_diff { - /// aiserver.v1.GitDiff.DiffType - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum DiffType { - Unspecified = 0, - DiffToHead = 1, - DiffFromBranchToMain = 2, - } - impl DiffType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "DIFF_TYPE_UNSPECIFIED", - Self::DiffToHead => "DIFF_TYPE_DIFF_TO_HEAD", - Self::DiffFromBranchToMain => "DIFF_TYPE_DIFF_FROM_BRANCH_TO_MAIN", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "DIFF_TYPE_UNSPECIFIED" => Some(Self::Unspecified), - "DIFF_TYPE_DIFF_TO_HEAD" => Some(Self::DiffToHead), - "DIFF_TYPE_DIFF_FROM_BRANCH_TO_MAIN" => Some(Self::DiffFromBranchToMain), - _ => None, - } - } - } -} -/// aiserver.v1.GetLintsForChangeResponse -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetLintsForChangeResponse { - #[prost(message, repeated, tag = "1")] - pub lints: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `GetLintsForChangeResponse`. -pub mod get_lints_for_change_response { - /// aiserver.v1.GetLintsForChangeResponse.Lint - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Lint { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub severity: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "4")] - pub start_line_number_one_indexed: i32, - #[prost(int32, tag = "5")] - pub start_column_one_indexed: i32, - #[prost(int32, tag = "6")] - pub end_line_number_inclusive_one_indexed: i32, - #[prost(int32, tag = "7")] - pub end_column_one_indexed: i32, - #[prost(message, repeated, tag = "9")] - pub quick_fixes: ::prost::alloc::vec::Vec, - } - /// Nested message and enum types in `Lint`. - pub mod lint { - /// aiserver.v1.GetLintsForChangeResponse.Lint.QuickFix - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct QuickFix { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub kind: ::prost::alloc::string::String, - #[prost(bool, tag = "3")] - pub is_preferred: bool, - #[prost(message, repeated, tag = "4")] - pub edits: ::prost::alloc::vec::Vec, - } - /// Nested message and enum types in `QuickFix`. - pub mod quick_fix { - /// aiserver.v1.GetLintsForChangeResponse.Lint.QuickFix.Edit - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Edit { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub text: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub start_line_number_one_indexed: i32, - #[prost(int32, tag = "4")] - pub start_column_one_indexed: i32, - #[prost(int32, tag = "5")] - pub end_line_number_inclusive_one_indexed: i32, - #[prost(int32, tag = "6")] - pub end_column_one_indexed: i32, - } - } - } -} -/// aiserver.v1.Lint -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Lint { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub range: ::core::option::Option, - #[prost(enumeration = "LintSeverity", tag = "3")] - pub severity: i32, -} -/// aiserver.v1.Edit -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Edit { - #[prost(string, tag = "1")] - pub text: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub range: ::core::option::Option, -} -/// aiserver.v1.IRange -#[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct IRange { - #[prost(int32, tag = "1")] - pub start_line_number: i32, - #[prost(int32, tag = "2")] - pub start_column: i32, - #[prost(int32, tag = "3")] - pub end_line_number: i32, - #[prost(int32, tag = "4")] - pub end_column: i32, -} -/// aiserver.v1.FolderInfo -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FolderInfo { - #[prost(string, tag = "1")] - pub relative_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub files: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.FolderFileInfo -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FolderFileInfo { - #[prost(string, tag = "1")] - pub relative_path: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub content: ::prost::alloc::string::String, - #[prost(bool, tag = "3")] - pub truncated: bool, - #[prost(float, tag = "4")] - pub score: f32, -} -/// aiserver.v1.DocsReference -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DocsReference { - #[prost(string, tag = "1")] - pub title: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub url: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub chunk: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub name: ::prost::alloc::string::String, -} -/// aiserver.v1.DiffHistoryData -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DiffHistoryData { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub diffs: ::prost::alloc::vec::Vec, - #[prost(double, tag = "3")] - pub timestamp: f64, - #[prost(string, tag = "4")] - pub unique_id: ::prost::alloc::string::String, - #[prost(message, optional, tag = "5")] - pub start_to_end_diff: ::core::option::Option, -} /// aiserver.v1.ComposerFileDiff #[derive(Clone, PartialEq, ::prost::Message)] pub struct ComposerFileDiff { @@ -2269,7 +3182,6 @@ pub mod composer_file_diff { pub lines_added: i32, } /// aiserver.v1.ComposerFileDiff.Editor - #[allow(clippy::enum_variant_names)] #[derive( Clone, Copy, @@ -2310,1264 +3222,19 @@ pub mod composer_file_diff { } } } -/// aiserver.v1.ConversationSummary +/// aiserver.v1.DiffHistoryData #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ConversationSummary { - #[prost(string, tag = "1")] - pub summary: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub truncation_last_bubble_id_inclusive: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub client_should_start_sending_from_inclusive_bubble_id: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub previous_conversation_summary_bubble_id: ::prost::alloc::string::String, - #[prost(bool, tag = "5")] - pub includes_tool_results: bool, -} -/// aiserver.v1.ComposerFileDiffHistory -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ComposerFileDiffHistory { - #[prost(string, tag = "1")] - pub file_name: ::prost::alloc::string::String, - #[prost(string, repeated, tag = "2")] - pub diff_history: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(double, repeated, tag = "3")] - pub diff_history_timestamps: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.ComposerCapabilityRequest -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ComposerCapabilityRequest { - #[prost( - enumeration = "composer_capability_request::ComposerCapabilityType", - tag = "1" - )] - pub r#type: i32, - #[prost( - oneof = "composer_capability_request::Data", - tags = "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14" - )] - pub data: ::core::option::Option, -} -/// Nested message and enum types in `ComposerCapabilityRequest`. -pub mod composer_capability_request { - /// aiserver.v1.ComposerCapabilityRequest.ToolSchema - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ToolSchema { - #[prost(enumeration = "ToolType", tag = "1")] - pub r#type: i32, - #[prost(string, tag = "2")] - pub name: ::prost::alloc::string::String, - #[prost(map = "string, message", tag = "3")] - pub properties: ::std::collections::HashMap< - ::prost::alloc::string::String, - SchemaProperty, - >, - #[prost(string, repeated, tag = "4")] - pub required: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.SchemaProperty - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct SchemaProperty { - #[prost(string, tag = "1")] - pub r#type: ::prost::alloc::string::String, - #[prost(string, optional, tag = "2")] - pub description: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.LoopOnLintsCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct LoopOnLintsCapability { - #[prost(message, repeated, tag = "1")] - pub linter_errors: ::prost::alloc::vec::Vec, - #[prost(string, optional, tag = "2")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.LoopOnTestsCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct LoopOnTestsCapability { - #[prost(string, repeated, tag = "1")] - pub test_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, optional, tag = "2")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.MegaPlannerCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct MegaPlannerCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.LoopOnCommandCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct LoopOnCommandCapability { - #[prost(string, tag = "1")] - pub command: ::prost::alloc::string::String, - #[prost(string, optional, tag = "2")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "3")] - pub output: ::core::option::Option<::prost::alloc::string::String>, - #[prost(int32, optional, tag = "4")] - pub exit_code: ::core::option::Option, - } - /// aiserver.v1.ComposerCapabilityRequest.ToolCallCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ToolCallCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "2")] - pub tool_schemas: ::prost::alloc::vec::Vec, - #[prost(string, repeated, tag = "3")] - pub relevant_files: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "4")] - pub files_in_context: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "5")] - pub semantic_search_files: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, - } - /// aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct DiffReviewCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "2")] - pub diffs: ::prost::alloc::vec::Vec, - } - /// Nested message and enum types in `DiffReviewCapability`. - pub mod diff_review_capability { - /// aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability.SimpleFileDiff - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct SimpleFileDiff { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "3")] - pub chunks: ::prost::alloc::vec::Vec, - } - /// Nested message and enum types in `SimpleFileDiff`. - pub mod simple_file_diff { - /// aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability.SimpleFileDiff.Chunk - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct Chunk { - #[prost(string, repeated, tag = "1")] - pub old_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "2")] - pub new_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(message, optional, tag = "3")] - pub old_range: ::core::option::Option, - #[prost(message, optional, tag = "4")] - pub new_range: ::core::option::Option, - } - } - } - /// aiserver.v1.ComposerCapabilityRequest.DecomposerCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct DecomposerCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.ContextPickingCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ContextPickingCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "2")] - pub potential_context_files: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, - #[prost(message, repeated, tag = "3")] - pub potential_context_code_chunks: ::prost::alloc::vec::Vec, - #[prost(string, repeated, tag = "4")] - pub files_in_context: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.EditTrailCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct EditTrailCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.AutoContextCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct AutoContextCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "2")] - pub additional_files: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.ContextPlannerCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ContextPlannerCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "2")] - pub attached_code_chunks: ::prost::alloc::vec::Vec, - } - /// aiserver.v1.ComposerCapabilityRequest.RememberThisCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct RememberThisCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, tag = "2")] - pub memory: ::prost::alloc::string::String, - } - /// aiserver.v1.ComposerCapabilityRequest.CursorRulesCapability - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct CursorRulesCapability { - #[prost(string, optional, tag = "1")] - pub custom_instructions: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.ComposerCapabilityRequest.ComposerCapabilityType - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum ComposerCapabilityType { - Unspecified = 0, - LoopOnLints = 1, - LoopOnTests = 2, - MegaPlanner = 3, - LoopOnCommand = 4, - ToolCall = 5, - DiffReview = 6, - ContextPicking = 7, - EditTrail = 8, - AutoContext = 9, - ContextPlanner = 10, - DiffHistory = 11, - RememberThis = 12, - Decomposer = 13, - UsesCodebase = 14, - ToolFormer = 15, - CursorRules = 16, - } - impl ComposerCapabilityType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "COMPOSER_CAPABILITY_TYPE_UNSPECIFIED", - Self::LoopOnLints => "COMPOSER_CAPABILITY_TYPE_LOOP_ON_LINTS", - Self::LoopOnTests => "COMPOSER_CAPABILITY_TYPE_LOOP_ON_TESTS", - Self::MegaPlanner => "COMPOSER_CAPABILITY_TYPE_MEGA_PLANNER", - Self::LoopOnCommand => "COMPOSER_CAPABILITY_TYPE_LOOP_ON_COMMAND", - Self::ToolCall => "COMPOSER_CAPABILITY_TYPE_TOOL_CALL", - Self::DiffReview => "COMPOSER_CAPABILITY_TYPE_DIFF_REVIEW", - Self::ContextPicking => "COMPOSER_CAPABILITY_TYPE_CONTEXT_PICKING", - Self::EditTrail => "COMPOSER_CAPABILITY_TYPE_EDIT_TRAIL", - Self::AutoContext => "COMPOSER_CAPABILITY_TYPE_AUTO_CONTEXT", - Self::ContextPlanner => "COMPOSER_CAPABILITY_TYPE_CONTEXT_PLANNER", - Self::DiffHistory => "COMPOSER_CAPABILITY_TYPE_DIFF_HISTORY", - Self::RememberThis => "COMPOSER_CAPABILITY_TYPE_REMEMBER_THIS", - Self::Decomposer => "COMPOSER_CAPABILITY_TYPE_DECOMPOSER", - Self::UsesCodebase => "COMPOSER_CAPABILITY_TYPE_USES_CODEBASE", - Self::ToolFormer => "COMPOSER_CAPABILITY_TYPE_TOOL_FORMER", - Self::CursorRules => "COMPOSER_CAPABILITY_TYPE_CURSOR_RULES", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "COMPOSER_CAPABILITY_TYPE_UNSPECIFIED" => Some(Self::Unspecified), - "COMPOSER_CAPABILITY_TYPE_LOOP_ON_LINTS" => Some(Self::LoopOnLints), - "COMPOSER_CAPABILITY_TYPE_LOOP_ON_TESTS" => Some(Self::LoopOnTests), - "COMPOSER_CAPABILITY_TYPE_MEGA_PLANNER" => Some(Self::MegaPlanner), - "COMPOSER_CAPABILITY_TYPE_LOOP_ON_COMMAND" => Some(Self::LoopOnCommand), - "COMPOSER_CAPABILITY_TYPE_TOOL_CALL" => Some(Self::ToolCall), - "COMPOSER_CAPABILITY_TYPE_DIFF_REVIEW" => Some(Self::DiffReview), - "COMPOSER_CAPABILITY_TYPE_CONTEXT_PICKING" => Some(Self::ContextPicking), - "COMPOSER_CAPABILITY_TYPE_EDIT_TRAIL" => Some(Self::EditTrail), - "COMPOSER_CAPABILITY_TYPE_AUTO_CONTEXT" => Some(Self::AutoContext), - "COMPOSER_CAPABILITY_TYPE_CONTEXT_PLANNER" => Some(Self::ContextPlanner), - "COMPOSER_CAPABILITY_TYPE_DIFF_HISTORY" => Some(Self::DiffHistory), - "COMPOSER_CAPABILITY_TYPE_REMEMBER_THIS" => Some(Self::RememberThis), - "COMPOSER_CAPABILITY_TYPE_DECOMPOSER" => Some(Self::Decomposer), - "COMPOSER_CAPABILITY_TYPE_USES_CODEBASE" => Some(Self::UsesCodebase), - "COMPOSER_CAPABILITY_TYPE_TOOL_FORMER" => Some(Self::ToolFormer), - "COMPOSER_CAPABILITY_TYPE_CURSOR_RULES" => Some(Self::CursorRules), - _ => None, - } - } - } - /// aiserver.v1.ComposerCapabilityRequest.ToolType - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum ToolType { - Unspecified = 0, - AddFileToContext = 1, - RunTerminalCommand = 2, - Iterate = 3, - RemoveFileFromContext = 4, - SemanticSearchCodebase = 5, - } - impl ToolType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "TOOL_TYPE_UNSPECIFIED", - Self::AddFileToContext => "TOOL_TYPE_ADD_FILE_TO_CONTEXT", - Self::RunTerminalCommand => "TOOL_TYPE_RUN_TERMINAL_COMMAND", - Self::Iterate => "TOOL_TYPE_ITERATE", - Self::RemoveFileFromContext => "TOOL_TYPE_REMOVE_FILE_FROM_CONTEXT", - Self::SemanticSearchCodebase => "TOOL_TYPE_SEMANTIC_SEARCH_CODEBASE", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "TOOL_TYPE_UNSPECIFIED" => Some(Self::Unspecified), - "TOOL_TYPE_ADD_FILE_TO_CONTEXT" => Some(Self::AddFileToContext), - "TOOL_TYPE_RUN_TERMINAL_COMMAND" => Some(Self::RunTerminalCommand), - "TOOL_TYPE_ITERATE" => Some(Self::Iterate), - "TOOL_TYPE_REMOVE_FILE_FROM_CONTEXT" => Some(Self::RemoveFileFromContext), - "TOOL_TYPE_SEMANTIC_SEARCH_CODEBASE" => { - Some(Self::SemanticSearchCodebase) - } - _ => None, - } - } - } - #[allow(clippy::enum_variant_names)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Data { - #[prost(message, tag = "2")] - LoopOnLints(LoopOnLintsCapability), - #[prost(message, tag = "3")] - LoopOnTests(LoopOnTestsCapability), - #[prost(message, tag = "4")] - MegaPlanner(MegaPlannerCapability), - #[prost(message, tag = "5")] - LoopOnCommand(LoopOnCommandCapability), - #[prost(message, tag = "6")] - ToolCall(ToolCallCapability), - #[prost(message, tag = "7")] - DiffReview(DiffReviewCapability), - #[prost(message, tag = "8")] - ContextPicking(ContextPickingCapability), - #[prost(message, tag = "9")] - EditTrail(EditTrailCapability), - #[prost(message, tag = "10")] - AutoContext(AutoContextCapability), - #[prost(message, tag = "11")] - ContextPlanner(ContextPlannerCapability), - #[prost(message, tag = "12")] - RememberThis(RememberThisCapability), - #[prost(message, tag = "13")] - Decomposer(DecomposerCapability), - #[prost(message, tag = "14")] - CursorRules(CursorRulesCapability), - } -} -/// aiserver.v1.CodeChunk -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CodeChunk { +pub struct DiffHistoryData { #[prost(string, tag = "1")] pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub start_line_number: i32, - #[prost(string, repeated, tag = "3")] - pub lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(enumeration = "code_chunk::SummarizationStrategy", optional, tag = "4")] - pub summarization_strategy: ::core::option::Option, - #[prost(string, tag = "5")] - pub language_identifier: ::prost::alloc::string::String, - #[prost(enumeration = "code_chunk::Intent", optional, tag = "6")] - pub intent: ::core::option::Option, - #[prost(bool, optional, tag = "7")] - pub is_final_version: ::core::option::Option, - #[prost(bool, optional, tag = "8")] - pub is_first_version: ::core::option::Option, -} -/// Nested message and enum types in `CodeChunk`. -pub mod code_chunk { - /// aiserver.v1.CodeChunk.Intent - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum Intent { - Unspecified = 0, - ComposerFile = 1, - CompressedComposerFile = 2, - } - impl Intent { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "INTENT_UNSPECIFIED", - Self::ComposerFile => "INTENT_COMPOSER_FILE", - Self::CompressedComposerFile => "INTENT_COMPRESSED_COMPOSER_FILE", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "INTENT_UNSPECIFIED" => Some(Self::Unspecified), - "INTENT_COMPOSER_FILE" => Some(Self::ComposerFile), - "INTENT_COMPRESSED_COMPOSER_FILE" => Some(Self::CompressedComposerFile), - _ => None, - } - } - } - /// aiserver.v1.CodeChunk.SummarizationStrategy - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum SummarizationStrategy { - NoneUnspecified = 0, - Summarized = 1, - Embedded = 2, - } - impl SummarizationStrategy { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::NoneUnspecified => "SUMMARIZATION_STRATEGY_NONE_UNSPECIFIED", - Self::Summarized => "SUMMARIZATION_STRATEGY_SUMMARIZED", - Self::Embedded => "SUMMARIZATION_STRATEGY_EMBEDDED", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "SUMMARIZATION_STRATEGY_NONE_UNSPECIFIED" => Some(Self::NoneUnspecified), - "SUMMARIZATION_STRATEGY_SUMMARIZED" => Some(Self::Summarized), - "SUMMARIZATION_STRATEGY_EMBEDDED" => Some(Self::Embedded), - _ => None, - } - } - } -} -/// aiserver.v1.Commit -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Commit { - #[prost(string, tag = "1")] - pub sha: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub message: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub description: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "4")] - pub diff: ::prost::alloc::vec::Vec, - #[prost(string, tag = "5")] - pub author: ::prost::alloc::string::String, - #[prost(string, tag = "6")] - pub date: ::prost::alloc::string::String, -} -/// aiserver.v1.ClientSideToolV2Result -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ClientSideToolV2Result { - #[prost(enumeration = "ClientSideToolV2", tag = "1")] - pub tool: i32, - #[prost(message, optional, tag = "8")] - pub error: ::core::option::Option, - #[prost( - oneof = "client_side_tool_v2_result::Result", - tags = "2, 3, 4, 5, 6, 9, 10, 11, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30" - )] - pub result: ::core::option::Option, -} -/// Nested message and enum types in `ClientSideToolV2Result`. -pub mod client_side_tool_v2_result { - #[allow(clippy::enum_variant_names)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Result { - #[prost(message, tag = "2")] - ReadSemsearchFilesResult(super::ReadSemsearchFilesResult), - #[prost(message, tag = "3")] - ReadFileForImportsResult(super::ReadFileForImportsResult), - #[prost(message, tag = "4")] - RipgrepSearchResult(super::RipgrepSearchResult), - #[prost(message, tag = "5")] - RunTerminalCommandResult(super::RunTerminalCommandResult), - #[prost(message, tag = "6")] - ReadFileResult(super::ReadFileResult), - #[prost(message, tag = "9")] - ListDirResult(super::ListDirResult), - #[prost(message, tag = "10")] - EditFileResult(super::EditFileResult), - #[prost(message, tag = "11")] - FileSearchResult(super::ToolCallFileSearchResult), - #[prost(message, tag = "18")] - SemanticSearchFullResult(super::SemanticSearchFullResult), - #[prost(message, tag = "19")] - CreateFileResult(super::CreateFileResult), - #[prost(message, tag = "20")] - DeleteFileResult(super::DeleteFileResult), - #[prost(message, tag = "21")] - ReapplyResult(super::ReapplyResult), - #[prost(message, tag = "22")] - GetRelatedFilesResult(super::GetRelatedFilesResult), - #[prost(message, tag = "23")] - ParallelApplyResult(super::ParallelApplyResult), - #[prost(message, tag = "24")] - RunTerminalCommandV2Result(super::RunTerminalCommandV2Result), - #[prost(message, tag = "25")] - FetchRulesResult(super::FetchRulesResult), - #[prost(message, tag = "26")] - PlannerResult(super::PlannerResult), - #[prost(message, tag = "27")] - WebSearchResult(super::WebSearchResult), - #[prost(message, tag = "28")] - McpResult(super::McpResult), - #[prost(message, tag = "29")] - WebViewerResult(super::WebViewerResult), - #[prost(message, tag = "30")] - DiffHistoryResult(super::DiffHistoryResult), - } -} -/// aiserver.v1.WebViewerResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct WebViewerResult { - #[prost(string, tag = "1")] - pub url: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub screenshot: ::core::option::Option, -} -/// aiserver.v1.WebSearchResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct WebSearchResult { - #[prost(message, repeated, tag = "1")] - pub references: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `WebSearchResult`. -pub mod web_search_result { - /// aiserver.v1.WebSearchResult.WebReference - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct WebReference { - #[prost(string, tag = "1")] - pub title: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub url: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub chunk: ::prost::alloc::string::String, - } -} -/// aiserver.v1.ToolCallFileSearchResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ToolCallFileSearchResult { - #[prost(message, repeated, tag = "1")] - pub files: ::prost::alloc::vec::Vec, - #[prost(bool, optional, tag = "2")] - pub limit_hit: ::core::option::Option, - #[prost(int32, tag = "3")] - pub num_results: i32, -} -/// Nested message and enum types in `ToolCallFileSearchResult`. -pub mod tool_call_file_search_result { - /// aiserver.v1.ToolCallFileSearchResult.File - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct File { - #[prost(string, tag = "1")] - pub uri: ::prost::alloc::string::String, - } -} -/// aiserver.v1.SemanticSearchFullResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SemanticSearchFullResult { - #[prost(message, repeated, tag = "1")] - pub code_results: ::prost::alloc::vec::Vec, #[prost(message, repeated, tag = "2")] - pub all_files: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "3")] - pub missing_files: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.RunTerminalCommandV2Result -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RunTerminalCommandV2Result { - #[prost(string, tag = "1")] - pub output: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub exit_code: i32, - #[prost(bool, optional, tag = "3")] - pub rejected: ::core::option::Option, - #[prost(bool, tag = "4")] - pub popped_out_into_background: bool, - #[prost(bool, tag = "5")] - pub is_running_in_background: bool, - #[prost(bool, tag = "6")] - pub not_interrupted: bool, - #[prost(string, tag = "7")] - pub resulting_working_directory: ::prost::alloc::string::String, - #[prost(bool, tag = "8")] - pub did_user_change: bool, - #[prost(enumeration = "RunTerminalCommandEndedReason", tag = "9")] - pub ended_reason: i32, - #[prost(int32, optional, tag = "10")] - pub exit_code_v2: ::core::option::Option, -} -/// aiserver.v1.RunTerminalCommandResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RunTerminalCommandResult { - #[prost(string, tag = "1")] - pub output: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub exit_code: i32, - #[prost(bool, optional, tag = "3")] - pub rejected: ::core::option::Option, - #[prost(bool, tag = "4")] - pub popped_out_into_background: bool, -} -/// aiserver.v1.RipgrepSearchResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RipgrepSearchResult { - #[prost(message, optional, tag = "1")] - pub internal: ::core::option::Option, -} -/// aiserver.v1.RipgrepSearchResultInternal -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct RipgrepSearchResultInternal { - #[prost(message, repeated, tag = "1")] - pub results: ::prost::alloc::vec::Vec, - #[prost( - enumeration = "ripgrep_search_result_internal::SearchCompletionExitCode", - optional, - tag = "2" - )] - pub exit: ::core::option::Option, - #[prost(bool, optional, tag = "3")] - pub limit_hit: ::core::option::Option, - #[prost(message, repeated, tag = "4")] - pub messages: ::prost::alloc::vec::Vec< - ripgrep_search_result_internal::ITextSearchCompleteMessage, - >, - #[prost(oneof = "ripgrep_search_result_internal::Stats", tags = "5, 6")] - pub stats: ::core::option::Option, -} -/// Nested message and enum types in `RipgrepSearchResultInternal`. -pub mod ripgrep_search_result_internal { - /// aiserver.v1.RipgrepSearchResultInternal.IFileMatch - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct IFileMatch { - #[prost(string, tag = "1")] - pub resource: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub results: ::prost::alloc::vec::Vec, - } - /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchResult - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ITextSearchResult { - #[prost(oneof = "i_text_search_result::Result", tags = "1, 2")] - pub result: ::core::option::Option, - } - /// Nested message and enum types in `ITextSearchResult`. - pub mod i_text_search_result { - #[allow(clippy::enum_variant_names)] - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Result { - #[prost(message, tag = "1")] - Match(super::ITextSearchMatch), - #[prost(message, tag = "2")] - Context(super::ITextSearchContext), - } - } - /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchMatch - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ITextSearchMatch { - #[prost(string, optional, tag = "1")] - pub uri: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "2")] - pub range_locations: ::prost::alloc::vec::Vec, - #[prost(string, tag = "3")] - pub preview_text: ::prost::alloc::string::String, - #[prost(int32, optional, tag = "4")] - pub webview_index: ::core::option::Option, - #[prost(string, optional, tag = "5")] - pub cell_fragment: ::core::option::Option<::prost::alloc::string::String>, - } - /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchContext - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ITextSearchContext { - #[prost(string, optional, tag = "1")] - pub uri: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, tag = "2")] - pub text: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub line_number: i32, - } - /// aiserver.v1.RipgrepSearchResultInternal.ISearchRangeSetPairing - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct ISearchRangeSetPairing { - #[prost(message, optional, tag = "1")] - pub source: ::core::option::Option, - #[prost(message, optional, tag = "2")] - pub preview: ::core::option::Option, - } - /// aiserver.v1.RipgrepSearchResultInternal.ISearchRange - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct ISearchRange { - #[prost(int32, tag = "1")] - pub start_line_number: i32, - #[prost(int32, tag = "2")] - pub start_column: i32, - #[prost(int32, tag = "3")] - pub end_line_number: i32, - #[prost(int32, tag = "4")] - pub end_column: i32, - } - /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchCompleteMessage - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ITextSearchCompleteMessage { - #[prost(string, tag = "1")] - pub text: ::prost::alloc::string::String, - #[prost(enumeration = "TextSearchCompleteMessageType", tag = "2")] - pub r#type: i32, - #[prost(bool, optional, tag = "3")] - pub trusted: ::core::option::Option, - } - /// aiserver.v1.RipgrepSearchResultInternal.IFileSearchStats - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct IFileSearchStats { - #[prost(bool, tag = "1")] - pub from_cache: bool, - #[prost(int32, tag = "5")] - pub result_count: i32, - #[prost(enumeration = "i_file_search_stats::FileSearchProviderType", tag = "6")] - pub r#type: i32, - #[prost(int32, optional, tag = "7")] - pub sorting_time: ::core::option::Option, - #[prost(oneof = "i_file_search_stats::DetailStats", tags = "2, 3, 4")] - pub detail_stats: ::core::option::Option, - } - /// Nested message and enum types in `IFileSearchStats`. - pub mod i_file_search_stats { - /// aiserver.v1.RipgrepSearchResultInternal.IFileSearchStats.FileSearchProviderType - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum FileSearchProviderType { - Unspecified = 0, - FileSearchProvider = 1, - SearchProcess = 2, - } - impl FileSearchProviderType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "FILE_SEARCH_PROVIDER_TYPE_UNSPECIFIED", - Self::FileSearchProvider => { - "FILE_SEARCH_PROVIDER_TYPE_FILE_SEARCH_PROVIDER" - } - Self::SearchProcess => "FILE_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "FILE_SEARCH_PROVIDER_TYPE_UNSPECIFIED" => Some(Self::Unspecified), - "FILE_SEARCH_PROVIDER_TYPE_FILE_SEARCH_PROVIDER" => { - Some(Self::FileSearchProvider) - } - "FILE_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS" => { - Some(Self::SearchProcess) - } - _ => None, - } - } - } - #[allow(clippy::enum_variant_names)] - #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] - pub enum DetailStats { - #[prost(message, tag = "2")] - SearchEngineStats(super::ISearchEngineStats), - #[prost(message, tag = "3")] - CachedSearchStats(super::ICachedSearchStats), - #[prost(message, tag = "4")] - FileSearchProviderStats(super::IFileSearchProviderStats), - } - } - /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchStats - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct ITextSearchStats { - #[prost(enumeration = "i_text_search_stats::TextSearchProviderType", tag = "1")] - pub r#type: i32, - } - /// Nested message and enum types in `ITextSearchStats`. - pub mod i_text_search_stats { - /// aiserver.v1.RipgrepSearchResultInternal.ITextSearchStats.TextSearchProviderType - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum TextSearchProviderType { - Unspecified = 0, - TextSearchProvider = 1, - SearchProcess = 2, - AiTextSearchProvider = 3, - } - impl TextSearchProviderType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "TEXT_SEARCH_PROVIDER_TYPE_UNSPECIFIED", - Self::TextSearchProvider => { - "TEXT_SEARCH_PROVIDER_TYPE_TEXT_SEARCH_PROVIDER" - } - Self::SearchProcess => "TEXT_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS", - Self::AiTextSearchProvider => { - "TEXT_SEARCH_PROVIDER_TYPE_AI_TEXT_SEARCH_PROVIDER" - } - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "TEXT_SEARCH_PROVIDER_TYPE_UNSPECIFIED" => Some(Self::Unspecified), - "TEXT_SEARCH_PROVIDER_TYPE_TEXT_SEARCH_PROVIDER" => { - Some(Self::TextSearchProvider) - } - "TEXT_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS" => { - Some(Self::SearchProcess) - } - "TEXT_SEARCH_PROVIDER_TYPE_AI_TEXT_SEARCH_PROVIDER" => { - Some(Self::AiTextSearchProvider) - } - _ => None, - } - } - } - } - /// aiserver.v1.RipgrepSearchResultInternal.ISearchEngineStats - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct ISearchEngineStats { - #[prost(int32, tag = "1")] - pub file_walk_time: i32, - #[prost(int32, tag = "2")] - pub directories_walked: i32, - #[prost(int32, tag = "3")] - pub files_walked: i32, - #[prost(int32, tag = "4")] - pub cmd_time: i32, - #[prost(int32, optional, tag = "5")] - pub cmd_result_count: ::core::option::Option, - } - /// aiserver.v1.RipgrepSearchResultInternal.ICachedSearchStats - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct ICachedSearchStats { - #[prost(bool, tag = "1")] - pub cache_was_resolved: bool, - #[prost(int32, tag = "2")] - pub cache_lookup_time: i32, - #[prost(int32, tag = "3")] - pub cache_filter_time: i32, - #[prost(int32, tag = "4")] - pub cache_entry_count: i32, - } - /// aiserver.v1.RipgrepSearchResultInternal.IFileSearchProviderStats - #[derive(Clone, Copy, PartialEq, ::prost::Message)] - pub struct IFileSearchProviderStats { - #[prost(int32, tag = "1")] - pub provider_time: i32, - #[prost(int32, tag = "2")] - pub post_process_time: i32, - } - /// aiserver.v1.RipgrepSearchResultInternal.TextSearchCompleteMessageType - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum TextSearchCompleteMessageType { - Unspecified = 0, - Information = 1, - Warning = 2, - } - impl TextSearchCompleteMessageType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_UNSPECIFIED", - Self::Information => "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_INFORMATION", - Self::Warning => "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_WARNING", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_UNSPECIFIED" => { - Some(Self::Unspecified) - } - "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_INFORMATION" => { - Some(Self::Information) - } - "TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_WARNING" => Some(Self::Warning), - _ => None, - } - } - } - /// aiserver.v1.RipgrepSearchResultInternal.SearchCompletionExitCode - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum SearchCompletionExitCode { - Unspecified = 0, - Normal = 1, - NewSearchStarted = 2, - } - impl SearchCompletionExitCode { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "SEARCH_COMPLETION_EXIT_CODE_UNSPECIFIED", - Self::Normal => "SEARCH_COMPLETION_EXIT_CODE_NORMAL", - Self::NewSearchStarted => { - "SEARCH_COMPLETION_EXIT_CODE_NEW_SEARCH_STARTED" - } - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "SEARCH_COMPLETION_EXIT_CODE_UNSPECIFIED" => Some(Self::Unspecified), - "SEARCH_COMPLETION_EXIT_CODE_NORMAL" => Some(Self::Normal), - "SEARCH_COMPLETION_EXIT_CODE_NEW_SEARCH_STARTED" => { - Some(Self::NewSearchStarted) - } - _ => None, - } - } - } - #[allow(clippy::enum_variant_names)] - #[derive(Clone, Copy, PartialEq, ::prost::Oneof)] - pub enum Stats { - #[prost(message, tag = "5")] - FileSearchStats(IFileSearchStats), - #[prost(message, tag = "6")] - TextSearchStats(ITextSearchStats), - } -} -/// aiserver.v1.ReapplyResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ReapplyResult { - #[prost(message, optional, tag = "1")] - pub diff: ::core::option::Option, - #[prost(bool, tag = "2")] - pub is_applied: bool, - #[prost(bool, tag = "3")] - pub apply_failed: bool, - #[prost(message, repeated, tag = "4")] - pub linter_errors: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.ReadFileResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ReadFileResult { - #[prost(string, tag = "1")] - pub contents: ::prost::alloc::string::String, - #[prost(bool, tag = "2")] - pub did_downgrade_to_line_range: bool, - #[prost(bool, tag = "3")] - pub did_shorten_line_range: bool, - #[prost(bool, tag = "4")] - pub did_set_default_line_range: bool, - #[prost(string, optional, tag = "5")] - pub full_file_contents: ::core::option::Option<::prost::alloc::string::String>, - #[prost(string, optional, tag = "6")] - pub outline: ::core::option::Option<::prost::alloc::string::String>, - #[prost(int32, optional, tag = "7")] - pub start_line_one_indexed: ::core::option::Option, - #[prost(int32, optional, tag = "8")] - pub end_line_one_indexed_inclusive: ::core::option::Option, - #[prost(string, tag = "9")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(bool, tag = "10")] - pub did_shorten_char_range: bool, -} -/// aiserver.v1.ReadFileForImportsResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ReadFileForImportsResult { - #[prost(string, tag = "1")] - pub contents: ::prost::alloc::string::String, -} -/// aiserver.v1.PlannerResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct PlannerResult { - #[prost(string, tag = "1")] - pub plan: ::prost::alloc::string::String, -} -/// aiserver.v1.ParallelApplyResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ParallelApplyResult { - #[prost(message, repeated, tag = "1")] - pub file_results: ::prost::alloc::vec::Vec, - #[prost(string, optional, tag = "2")] - pub error: ::core::option::Option<::prost::alloc::string::String>, -} -/// Nested message and enum types in `ParallelApplyResult`. -pub mod parallel_apply_result { - /// aiserver.v1.ParallelApplyResult.FileResult - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct FileResult { - #[prost(string, tag = "1")] - pub file_path: ::prost::alloc::string::String, - #[prost(message, optional, tag = "2")] - pub diff: ::core::option::Option, - #[prost(bool, tag = "3")] - pub is_applied: bool, - #[prost(bool, tag = "4")] - pub apply_failed: bool, - #[prost(string, optional, tag = "5")] - pub error: ::core::option::Option<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "6")] - pub linter_errors: ::prost::alloc::vec::Vec, - } -} -/// aiserver.v1.FileResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FileResult { - #[prost(message, optional, tag = "1")] - pub file: ::core::option::Option, - #[prost(float, tag = "2")] - pub score: f32, -} -/// aiserver.v1.MCPResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct McpResult { - #[prost(string, tag = "1")] - pub selected_tool: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub result: ::prost::alloc::string::String, -} -/// aiserver.v1.GetRelatedFilesResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct GetRelatedFilesResult { - #[prost(message, repeated, tag = "1")] - pub files: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `GetRelatedFilesResult`. -pub mod get_related_files_result { - /// aiserver.v1.GetRelatedFilesResult.File - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct File { - #[prost(string, tag = "1")] - pub uri: ::prost::alloc::string::String, - #[prost(float, tag = "2")] - pub score: f32, - } -} -/// aiserver.v1.FetchRulesResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FetchRulesResult { - #[prost(message, repeated, tag = "1")] - pub rules: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.EditFileResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct EditFileResult { - #[prost(message, optional, tag = "1")] - pub diff: ::core::option::Option, - #[prost(bool, tag = "2")] - pub is_applied: bool, - #[prost(bool, tag = "3")] - pub apply_failed: bool, - #[prost(message, repeated, tag = "4")] - pub linter_errors: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `EditFileResult`. -pub mod edit_file_result { - /// aiserver.v1.EditFileResult.FileDiff - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct FileDiff { - #[prost(message, repeated, tag = "1")] - pub chunks: ::prost::alloc::vec::Vec, - #[prost(enumeration = "file_diff::Editor", tag = "2")] - pub editor: i32, - #[prost(bool, tag = "3")] - pub hit_timeout: bool, - } - /// Nested message and enum types in `FileDiff`. - pub mod file_diff { - /// aiserver.v1.EditFileResult.FileDiff.ChunkDiff - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct ChunkDiff { - #[prost(string, tag = "1")] - pub diff_string: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub old_start: i32, - #[prost(int32, tag = "3")] - pub new_start: i32, - #[prost(int32, tag = "4")] - pub old_lines: i32, - #[prost(int32, tag = "5")] - pub new_lines: i32, - #[prost(int32, tag = "6")] - pub lines_removed: i32, - #[prost(int32, tag = "7")] - pub lines_added: i32, - } - /// aiserver.v1.EditFileResult.FileDiff.Editor - #[allow(clippy::enum_variant_names)] - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum Editor { - Unspecified = 0, - Ai = 1, - Human = 2, - } - impl Editor { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "EDITOR_UNSPECIFIED", - Self::Ai => "EDITOR_AI", - Self::Human => "EDITOR_HUMAN", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "EDITOR_UNSPECIFIED" => Some(Self::Unspecified), - "EDITOR_AI" => Some(Self::Ai), - "EDITOR_HUMAN" => Some(Self::Human), - _ => None, - } - } - } - } -} -/// aiserver.v1.DiffHistoryResult -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DiffHistoryResult { - #[prost(message, repeated, tag = "40")] - pub human_changes: ::prost::alloc::vec::Vec, -} -/// Nested message and enum types in `DiffHistoryResult`. -pub mod diff_history_result { - /// aiserver.v1.DiffHistoryResult.RenderedDiff - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct RenderedDiff { - #[prost(int32, tag = "1")] - pub start_line_number: i32, - #[prost(int32, tag = "2")] - pub end_line_number_exclusive: i32, - #[prost(string, repeated, tag = "3")] - pub before_context_lines: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, - #[prost(string, repeated, tag = "4")] - pub removed_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "5")] - pub added_lines: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(string, repeated, tag = "6")] - pub after_context_lines: ::prost::alloc::vec::Vec< - ::prost::alloc::string::String, - >, - } - /// aiserver.v1.DiffHistoryResult.HumanChange - #[derive(Clone, PartialEq, ::prost::Message)] - pub struct HumanChange { - #[prost(string, tag = "1")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub rendered_diffs: ::prost::alloc::vec::Vec, - } + pub diffs: ::prost::alloc::vec::Vec, + #[prost(double, tag = "3")] + pub timestamp: f64, + #[prost(string, tag = "4")] + pub unique_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "5")] + pub start_to_end_diff: ::core::option::Option, } /// aiserver.v1.ContextAST #[derive(Clone, PartialEq, ::prost::Message)] @@ -3633,7 +3300,6 @@ pub mod container_tree_node { #[prost(string, tag = "2")] pub relative_workspace_path: ::prost::alloc::string::String, } - #[allow(clippy::enum_variant_names)] #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum Node { #[prost(message, tag = "1")] @@ -3644,31 +3310,237 @@ pub mod container_tree_node { Symbol(Symbol), } } -/// aiserver.v1.CommitNote -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CommitNote { - #[prost(string, tag = "1")] - pub note: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub commit_hash: ::prost::alloc::string::String, +/// aiserver.v1.AvailableModelsRequest +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct AvailableModelsRequest { + #[prost(bool, tag = "1")] + pub is_nightly: bool, + #[prost(bool, tag = "2")] + pub include_long_context_models: bool, } -/// aiserver.v1.ChatQuote +/// aiserver.v1.AvailableModelsResponse #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ChatQuote { - #[prost(string, tag = "1")] - pub markdown: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub bubble_id: ::prost::alloc::string::String, - #[prost(int32, tag = "3")] - pub section_index: i32, +pub struct AvailableModelsResponse { + #[prost(message, repeated, tag = "2")] + pub models: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag = "1")] + pub model_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -/// aiserver.v1.ChatExternalLink +/// Nested message and enum types in `AvailableModelsResponse`. +pub mod available_models_response { + /// aiserver.v1.AvailableModelsResponse.TooltipData + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct TooltipData { + #[prost(string, tag = "1")] + pub primary_text: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub secondary_text: ::prost::alloc::string::String, + #[prost(bool, tag = "3")] + pub secondary_warning_text: bool, + #[prost(string, tag = "4")] + pub icon: ::prost::alloc::string::String, + } + /// aiserver.v1.AvailableModelsResponse.AvailableModel + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct AvailableModel { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(bool, tag = "2")] + pub default_on: bool, + #[prost(bool, optional, tag = "3")] + pub is_long_context_only: ::core::option::Option, + #[prost(bool, optional, tag = "4")] + pub is_chat_only: ::core::option::Option, + #[prost(bool, optional, tag = "5")] + pub supports_agent: ::core::option::Option, + #[prost(enumeration = "DegradationStatus", optional, tag = "6")] + pub degradation_status: ::core::option::Option, + #[prost(double, optional, tag = "7")] + pub price: ::core::option::Option, + #[prost(message, optional, tag = "8")] + pub tooltip_data: ::core::option::Option, + } + /// aiserver.v1.AvailableModelsResponse.DegradationStatus + #[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + Hash, + PartialOrd, + Ord, + ::prost::Enumeration + )] + #[repr(i32)] + pub enum DegradationStatus { + Unspecified = 0, + Degraded = 1, + Disabled = 2, + } + impl DegradationStatus { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "DEGRADATION_STATUS_UNSPECIFIED", + Self::Degraded => "DEGRADATION_STATUS_DEGRADED", + Self::Disabled => "DEGRADATION_STATUS_DISABLED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "DEGRADATION_STATUS_UNSPECIFIED" => Some(Self::Unspecified), + "DEGRADATION_STATUS_DEGRADED" => Some(Self::Degraded), + "DEGRADATION_STATUS_DISABLED" => Some(Self::Disabled), + _ => None, + } + } + } +} +/// aiserver.v1.DebugInfo #[derive(Clone, PartialEq, ::prost::Message)] -pub struct ChatExternalLink { - #[prost(string, tag = "1")] - pub url: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub uuid: ::prost::alloc::string::String, +pub struct DebugInfo { + #[prost(message, optional, tag = "1")] + pub breakpoint: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub call_stack: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "3")] + pub history: ::prost::alloc::vec::Vec, +} +/// Nested message and enum types in `DebugInfo`. +pub mod debug_info { + /// aiserver.v1.DebugInfo.Variable + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Variable { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub value: ::prost::alloc::string::String, + #[prost(string, optional, tag = "3")] + pub r#type: ::core::option::Option<::prost::alloc::string::String>, + } + /// aiserver.v1.DebugInfo.Scope + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Scope { + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "2")] + pub variables: ::prost::alloc::vec::Vec, + } + /// aiserver.v1.DebugInfo.CallStackFrame + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct CallStackFrame { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub line_number: i32, + #[prost(string, tag = "3")] + pub function_name: ::prost::alloc::string::String, + #[prost(message, repeated, tag = "4")] + pub scopes: ::prost::alloc::vec::Vec, + } + /// aiserver.v1.DebugInfo.Breakpoint + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct Breakpoint { + #[prost(string, tag = "1")] + pub relative_workspace_path: ::prost::alloc::string::String, + #[prost(int32, tag = "2")] + pub line_number: i32, + #[prost(string, repeated, tag = "3")] + pub lines_before_breakpoint: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, + #[prost(string, repeated, tag = "4")] + pub lines_after_breakpoint: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, + #[prost(string, optional, tag = "5")] + pub exception_info: ::core::option::Option<::prost::alloc::string::String>, + } +} +/// aiserver.v1.GetChatRequest +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetChatRequest { + #[prost(message, optional, tag = "1")] + pub current_file: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub conversation: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "3")] + pub repositories: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "4")] + pub explicit_context: ::core::option::Option, + #[prost(string, optional, tag = "5")] + pub workspace_root_path: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "6")] + pub code_blocks: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "7")] + pub model_details: ::core::option::Option, + #[prost(string, repeated, tag = "8")] + pub documentation_identifiers: ::prost::alloc::vec::Vec< + ::prost::alloc::string::String, + >, + #[prost(string, tag = "9")] + pub request_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "10")] + pub linter_errors: ::core::option::Option, + #[prost(string, optional, tag = "11")] + pub summary: ::core::option::Option<::prost::alloc::string::String>, + #[prost(int32, optional, tag = "12")] + pub summary_up_until_index: ::core::option::Option, + #[prost(bool, optional, tag = "13")] + pub allow_long_file_scan: ::core::option::Option, + #[prost(bool, optional, tag = "14")] + pub is_bash: ::core::option::Option, + #[prost(string, tag = "15")] + pub conversation_id: ::prost::alloc::string::String, + #[prost(bool, optional, tag = "16")] + pub can_handle_filenames_after_language_ids: ::core::option::Option, + #[prost(string, optional, tag = "17")] + pub use_web: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "18")] + pub quotes: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "19")] + pub debug_info: ::core::option::Option, + #[prost(string, optional, tag = "20")] + pub workspace_id: ::core::option::Option<::prost::alloc::string::String>, + #[prost(message, repeated, tag = "21")] + pub external_links: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag = "23")] + pub commit_notes: ::prost::alloc::vec::Vec, + #[prost(bool, optional, tag = "22")] + pub long_context_mode: ::core::option::Option, + #[prost(bool, optional, tag = "24")] + pub is_eval: ::core::option::Option, + #[prost(int32, optional, tag = "26")] + pub desired_max_tokens: ::core::option::Option, + #[prost(message, optional, tag = "25")] + pub context_ast: ::core::option::Option, + #[prost(bool, optional, tag = "27")] + pub is_composer: ::core::option::Option, + #[prost(bool, optional, tag = "28")] + pub runnable_code_blocks: ::core::option::Option, + #[prost(bool, optional, tag = "29")] + pub should_cache: ::core::option::Option, + #[prost(bool, optional, tag = "30")] + pub allow_model_fallbacks: ::core::option::Option, + #[prost(int32, optional, tag = "31")] + pub number_of_times_shown_fallback_model_warning: ::core::option::Option, +} +/// aiserver.v1.ServerTimingInfo +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct ServerTimingInfo { + #[prost(double, tag = "1")] + pub server_start_time: f64, + #[prost(double, tag = "2")] + pub server_first_token_time: f64, + #[prost(double, tag = "3")] + pub server_request_sent_time: f64, + #[prost(double, tag = "4")] + pub server_end_time: f64, } /// aiserver.v1.StreamChatResponse #[derive(Clone, PartialEq, ::prost::Message)] @@ -3711,9 +3583,21 @@ pub struct StreamChatResponse { pub conversation_summary: ::core::option::Option, #[prost(message, optional, tag = "17")] pub service_status_update: ::core::option::Option, + #[prost(message, optional, tag = "18")] + pub used_code: ::core::option::Option, + #[prost(bool, optional, tag = "26")] + pub stop_using_dsv3_agentic_model: ::core::option::Option, + #[prost(string, optional, tag = "27")] + pub usage_uuid: ::core::option::Option<::prost::alloc::string::String>, } /// Nested message and enum types in `StreamChatResponse`. pub mod stream_chat_response { + /// aiserver.v1.StreamChatResponse.UsedCode + #[derive(Clone, PartialEq, ::prost::Message)] + pub struct UsedCode { + #[prost(message, repeated, tag = "1")] + pub code_results: ::prost::alloc::vec::Vec, + } /// aiserver.v1.StreamChatResponse.ChunkIdentity #[derive(Clone, PartialEq, ::prost::Message)] pub struct ChunkIdentity { @@ -3729,96 +3613,21 @@ pub mod stream_chat_response { pub chunk_type: i32, } } -/// aiserver.v1.WebCitation +/// aiserver.v1.GetTokenUsageRequest #[derive(Clone, PartialEq, ::prost::Message)] -pub struct WebCitation { - #[prost(message, repeated, tag = "1")] - pub references: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.SymbolLink -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SymbolLink { +pub struct GetTokenUsageRequest { #[prost(string, tag = "1")] - pub symbol_name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub symbol_search_string: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub relative_workspace_path: ::prost::alloc::string::String, - #[prost(int32, tag = "4")] - pub rough_line_number: i32, + pub usage_uuid: ::prost::alloc::string::String, } -/// aiserver.v1.StatusUpdates -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct StatusUpdates { - #[prost(message, repeated, tag = "1")] - pub updates: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.StatusUpdate -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct StatusUpdate { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(string, optional, tag = "2")] - pub metadata: ::core::option::Option<::prost::alloc::string::String>, -} -/// aiserver.v1.ServiceStatusUpdate -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ServiceStatusUpdate { - #[prost(string, tag = "1")] - pub message: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub codicon: ::prost::alloc::string::String, - #[prost(bool, optional, tag = "3")] - pub allow_command_links_potentially_unsafe_please_only_use_for_handwritten_trusted_markdown: ::core::option::Option< - bool, - >, - #[prost(string, optional, tag = "4")] - pub action_to_run_on_status_update: ::core::option::Option< - ::prost::alloc::string::String, - >, -} -/// aiserver.v1.ServerTimingInfo +/// aiserver.v1.GetTokenUsageResponse #[derive(Clone, Copy, PartialEq, ::prost::Message)] -pub struct ServerTimingInfo { - #[prost(double, tag = "1")] - pub server_start_time: f64, - #[prost(double, tag = "2")] - pub server_first_token_time: f64, - #[prost(double, tag = "3")] - pub server_request_sent_time: f64, - #[prost(double, tag = "4")] - pub server_end_time: f64, -} -/// aiserver.v1.FileLink -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FileLink { - #[prost(string, tag = "1")] - pub display_name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub relative_workspace_path: ::prost::alloc::string::String, -} -/// aiserver.v1.DocumentationCitation -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DocumentationCitation { - #[prost(message, repeated, tag = "1")] - pub chunks: ::prost::alloc::vec::Vec, -} -/// aiserver.v1.DocumentationChunk -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DocumentationChunk { - #[prost(string, tag = "1")] - pub doc_name: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub page_url: ::prost::alloc::string::String, - #[prost(string, tag = "3")] - pub documentation_chunk: ::prost::alloc::string::String, - #[prost(float, tag = "4")] - pub score: f32, - #[prost(string, tag = "5")] - pub page_title: ::prost::alloc::string::String, +pub struct GetTokenUsageResponse { + #[prost(int32, tag = "1")] + pub input_tokens: i32, + #[prost(int32, tag = "2")] + pub output_tokens: i32, } /// aiserver.v1.EmbeddingModel -#[allow(clippy::enum_variant_names)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum EmbeddingModel { @@ -3851,130 +3660,7 @@ impl EmbeddingModel { } } } -/// aiserver.v1.BuiltinTool -#[allow(clippy::enum_variant_names)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum BuiltinTool { - Unspecified = 0, - Search = 1, - ReadChunk = 2, - Gotodef = 3, - Edit = 4, - UndoEdit = 5, - End = 6, - NewFile = 7, - AddTest = 8, - RunTest = 9, - DeleteTest = 10, - SaveFile = 11, - GetTests = 12, - GetSymbols = 13, - SemanticSearch = 14, - GetProjectStructure = 15, - CreateRmFiles = 16, - RunTerminalCommands = 17, - NewEdit = 18, - ReadWithLinter = 19, -} -impl BuiltinTool { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "BUILTIN_TOOL_UNSPECIFIED", - Self::Search => "BUILTIN_TOOL_SEARCH", - Self::ReadChunk => "BUILTIN_TOOL_READ_CHUNK", - Self::Gotodef => "BUILTIN_TOOL_GOTODEF", - Self::Edit => "BUILTIN_TOOL_EDIT", - Self::UndoEdit => "BUILTIN_TOOL_UNDO_EDIT", - Self::End => "BUILTIN_TOOL_END", - Self::NewFile => "BUILTIN_TOOL_NEW_FILE", - Self::AddTest => "BUILTIN_TOOL_ADD_TEST", - Self::RunTest => "BUILTIN_TOOL_RUN_TEST", - Self::DeleteTest => "BUILTIN_TOOL_DELETE_TEST", - Self::SaveFile => "BUILTIN_TOOL_SAVE_FILE", - Self::GetTests => "BUILTIN_TOOL_GET_TESTS", - Self::GetSymbols => "BUILTIN_TOOL_GET_SYMBOLS", - Self::SemanticSearch => "BUILTIN_TOOL_SEMANTIC_SEARCH", - Self::GetProjectStructure => "BUILTIN_TOOL_GET_PROJECT_STRUCTURE", - Self::CreateRmFiles => "BUILTIN_TOOL_CREATE_RM_FILES", - Self::RunTerminalCommands => "BUILTIN_TOOL_RUN_TERMINAL_COMMANDS", - Self::NewEdit => "BUILTIN_TOOL_NEW_EDIT", - Self::ReadWithLinter => "BUILTIN_TOOL_READ_WITH_LINTER", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "BUILTIN_TOOL_UNSPECIFIED" => Some(Self::Unspecified), - "BUILTIN_TOOL_SEARCH" => Some(Self::Search), - "BUILTIN_TOOL_READ_CHUNK" => Some(Self::ReadChunk), - "BUILTIN_TOOL_GOTODEF" => Some(Self::Gotodef), - "BUILTIN_TOOL_EDIT" => Some(Self::Edit), - "BUILTIN_TOOL_UNDO_EDIT" => Some(Self::UndoEdit), - "BUILTIN_TOOL_END" => Some(Self::End), - "BUILTIN_TOOL_NEW_FILE" => Some(Self::NewFile), - "BUILTIN_TOOL_ADD_TEST" => Some(Self::AddTest), - "BUILTIN_TOOL_RUN_TEST" => Some(Self::RunTest), - "BUILTIN_TOOL_DELETE_TEST" => Some(Self::DeleteTest), - "BUILTIN_TOOL_SAVE_FILE" => Some(Self::SaveFile), - "BUILTIN_TOOL_GET_TESTS" => Some(Self::GetTests), - "BUILTIN_TOOL_GET_SYMBOLS" => Some(Self::GetSymbols), - "BUILTIN_TOOL_SEMANTIC_SEARCH" => Some(Self::SemanticSearch), - "BUILTIN_TOOL_GET_PROJECT_STRUCTURE" => Some(Self::GetProjectStructure), - "BUILTIN_TOOL_CREATE_RM_FILES" => Some(Self::CreateRmFiles), - "BUILTIN_TOOL_RUN_TERMINAL_COMMANDS" => Some(Self::RunTerminalCommands), - "BUILTIN_TOOL_NEW_EDIT" => Some(Self::NewEdit), - "BUILTIN_TOOL_READ_WITH_LINTER" => Some(Self::ReadWithLinter), - _ => None, - } - } -} -/// aiserver.v1.LintSeverity -#[allow(clippy::enum_variant_names)] -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum LintSeverity { - Unspecified = 0, - Error = 1, - Warning = 2, - Info = 3, - Hint = 4, - Ai = 5, -} -impl LintSeverity { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Unspecified => "LINT_SEVERITY_UNSPECIFIED", - Self::Error => "LINT_SEVERITY_ERROR", - Self::Warning => "LINT_SEVERITY_WARNING", - Self::Info => "LINT_SEVERITY_INFO", - Self::Hint => "LINT_SEVERITY_HINT", - Self::Ai => "LINT_SEVERITY_AI", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "LINT_SEVERITY_UNSPECIFIED" => Some(Self::Unspecified), - "LINT_SEVERITY_ERROR" => Some(Self::Error), - "LINT_SEVERITY_WARNING" => Some(Self::Warning), - "LINT_SEVERITY_INFO" => Some(Self::Info), - "LINT_SEVERITY_HINT" => Some(Self::Hint), - "LINT_SEVERITY_AI" => Some(Self::Ai), - _ => None, - } - } -} /// aiserver.v1.ClientSideToolV2 -#[allow(clippy::enum_variant_names)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum ClientSideToolV2 { @@ -4000,6 +3686,9 @@ pub enum ClientSideToolV2 { Mcp = 19, WebViewer = 20, DiffHistory = 21, + Implementer = 22, + SearchSymbols = 23, + BackgroundComposerFollowup = 24, } impl ClientSideToolV2 { /// String value of the enum field names used in the ProtoBuf definition. @@ -4030,6 +3719,11 @@ impl ClientSideToolV2 { Self::Mcp => "CLIENT_SIDE_TOOL_V2_MCP", Self::WebViewer => "CLIENT_SIDE_TOOL_V2_WEB_VIEWER", Self::DiffHistory => "CLIENT_SIDE_TOOL_V2_DIFF_HISTORY", + Self::Implementer => "CLIENT_SIDE_TOOL_V2_IMPLEMENTER", + Self::SearchSymbols => "CLIENT_SIDE_TOOL_V2_SEARCH_SYMBOLS", + Self::BackgroundComposerFollowup => { + "CLIENT_SIDE_TOOL_V2_BACKGROUND_COMPOSER_FOLLOWUP" + } } } /// Creates an enum from field names used in the ProtoBuf definition. @@ -4059,12 +3753,16 @@ impl ClientSideToolV2 { "CLIENT_SIDE_TOOL_V2_MCP" => Some(Self::Mcp), "CLIENT_SIDE_TOOL_V2_WEB_VIEWER" => Some(Self::WebViewer), "CLIENT_SIDE_TOOL_V2_DIFF_HISTORY" => Some(Self::DiffHistory), + "CLIENT_SIDE_TOOL_V2_IMPLEMENTER" => Some(Self::Implementer), + "CLIENT_SIDE_TOOL_V2_SEARCH_SYMBOLS" => Some(Self::SearchSymbols), + "CLIENT_SIDE_TOOL_V2_BACKGROUND_COMPOSER_FOLLOWUP" => { + Some(Self::BackgroundComposerFollowup) + } _ => None, } } } /// aiserver.v1.RunTerminalCommandEndedReason -#[allow(clippy::enum_variant_names)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum RunTerminalCommandEndedReason { @@ -4115,7 +3813,6 @@ impl RunTerminalCommandEndedReason { } } /// aiserver.v1.ChunkType -#[allow(clippy::enum_variant_names)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum ChunkType { diff --git a/src/chat/aiserver/v1/lite.proto b/src/cursor/aiserver/v1/lite.proto similarity index 83% rename from src/chat/aiserver/v1/lite.proto rename to src/cursor/aiserver/v1/lite.proto index e975e97..bbb3710 100644 --- a/src/chat/aiserver/v1/lite.proto +++ b/src/cursor/aiserver/v1/lite.proto @@ -1,20 +1,171 @@ syntax = "proto3"; package aiserver.v1; import "timestamp.proto"; -message AvailableModelsRequest { // aiserver.v1.AvailableModelsRequest - bool is_nightly = 1; - bool include_long_context_models = 2; +enum EmbeddingModel { // aiserver.v1.EmbeddingModel + EMBEDDING_MODEL_UNSPECIFIED = 0; + EMBEDDING_MODEL_VOYAGE_CODE_2 = 1; + EMBEDDING_MODEL_TEXT_EMBEDDINGS_LARGE_3 = 2; + EMBEDDING_MODEL_QWEN_1_5B_CUSTOM = 3; } -message AvailableModelsResponse { // aiserver.v1.AvailableModelsResponse - message AvailableModel { // aiserver.v1.AvailableModelsResponse.AvailableModel - string name = 1; - bool default_on = 2; - optional bool is_long_context_only = 3; - optional bool is_chat_only = 4; - optional bool supports_agent = 5; +message CursorPosition { // aiserver.v1.CursorPosition + int32 line = 1; + int32 column = 2; +} +message SimplestRange { // aiserver.v1.SimplestRange + int32 start_line = 1; + int32 end_line_inclusive = 2; +} +message GitDiff { // aiserver.v1.GitDiff + enum DiffType { // aiserver.v1.GitDiff.DiffType + DIFF_TYPE_UNSPECIFIED = 0; + DIFF_TYPE_DIFF_TO_HEAD = 1; + DIFF_TYPE_DIFF_FROM_BRANCH_TO_MAIN = 2; } - repeated AvailableModel models = 2; - repeated string model_names = 1; + repeated FileDiff diffs = 1; + DiffType diff_type = 2; +} +message FileDiff { // aiserver.v1.FileDiff + message Chunk { // aiserver.v1.FileDiff.Chunk + string content = 1; + repeated string lines = 2; + int32 old_start = 3; + int32 old_lines = 4; + int32 new_start = 5; + int32 new_lines = 6; + } + string from = 1; + string to = 2; + repeated Chunk chunks = 3; +} +message LineRange { // aiserver.v1.LineRange + int32 start_line_number = 1; + int32 end_line_number_inclusive = 2; +} +message CursorRange { // aiserver.v1.CursorRange + CursorPosition start_position = 1; + CursorPosition end_position = 2; +} +message DetailedLine { // aiserver.v1.DetailedLine + string text = 1; + float line_number = 2; + bool is_signature = 3; +} +message CodeBlock { // aiserver.v1.CodeBlock + message Signatures { // aiserver.v1.CodeBlock.Signatures + repeated CursorRange ranges = 1; + } + string relative_workspace_path = 1; + optional string file_contents = 2; + optional int32 file_contents_length = 9; + CursorRange range = 3; + string contents = 4; + Signatures signatures = 5; + optional string override_contents = 6; + optional string original_contents = 7; + repeated DetailedLine detailed_lines = 8; +} +message File { // aiserver.v1.File + string relative_workspace_path = 1; + string contents = 2; +} +message Diagnostic { // aiserver.v1.Diagnostic + enum DiagnosticSeverity { // aiserver.v1.Diagnostic.DiagnosticSeverity + DIAGNOSTIC_SEVERITY_UNSPECIFIED = 0; + DIAGNOSTIC_SEVERITY_ERROR = 1; + DIAGNOSTIC_SEVERITY_WARNING = 2; + DIAGNOSTIC_SEVERITY_INFORMATION = 3; + DIAGNOSTIC_SEVERITY_HINT = 4; + } + message RelatedInformation { // aiserver.v1.Diagnostic.RelatedInformation + string message = 1; + CursorRange range = 2; + } + string message = 1; + CursorRange range = 2; + DiagnosticSeverity severity = 3; + repeated RelatedInformation related_information = 4; +} +message BM25Chunk { // aiserver.v1.BM25Chunk + string content = 1; + SimplestRange range = 2; + int32 score = 3; + string relative_path = 4; +} +message CurrentFileInfo { // aiserver.v1.CurrentFileInfo + message NotebookCell { // aiserver.v1.CurrentFileInfo.NotebookCell + } + string relative_workspace_path = 1; + string contents = 2; + bool rely_on_filesync = 18; + optional string sha_256_hash = 17; + repeated NotebookCell cells = 16; + repeated BM25Chunk top_chunks = 10; + int32 contents_start_at_line = 9; + CursorPosition cursor_position = 3; + repeated DataframeInfo dataframes = 4; + int32 total_number_of_lines = 8; + string language_id = 5; + CursorRange selection = 6; + optional int32 alternative_version_id = 11; + repeated Diagnostic diagnostics = 7; + optional int32 file_version = 14; + repeated int32 cell_start_lines = 15; + string workspace_root_path = 19; +} +message AzureState { // aiserver.v1.AzureState + string api_key = 1; + string base_url = 2; + string deployment = 3; + bool use_azure = 4; +} +message ModelDetails { // aiserver.v1.ModelDetails + optional string model_name = 1; + optional string api_key = 2; + optional bool enable_ghost_mode = 3; + optional AzureState azure_state = 4; + optional bool enable_slow_pool = 5; + optional string openai_api_base_url = 6; +} +message DataframeInfo { // aiserver.v1.DataframeInfo + message Column { // aiserver.v1.DataframeInfo.Column + string key = 1; + string type = 2; + } + string name = 1; + string shape = 2; + int32 data_dimensionality = 3; + repeated Column columns = 6; + int32 row_count = 7; + string index_column = 8; +} +message LinterError { // aiserver.v1.LinterError + string message = 1; + CursorRange range = 2; + optional string source = 3; + repeated Diagnostic.RelatedInformation related_information = 4; + optional Diagnostic.DiagnosticSeverity severity = 5; +} +message LinterErrors { // aiserver.v1.LinterErrors + string relative_workspace_path = 1; + repeated LinterError errors = 2; + string file_contents = 3; +} +message LinterErrorsWithoutFileContents { // aiserver.v1.LinterErrorsWithoutFileContents + string relative_workspace_path = 1; + repeated LinterError errors = 2; +} +message CursorRule { // aiserver.v1.CursorRule + string name = 1; + string description = 2; + optional string body = 3; + optional bool is_from_glob = 4; + optional bool always_apply = 5; +} +message ExplicitContext { // aiserver.v1.ExplicitContext + string context = 1; + optional string repo_context = 2; + repeated CursorRule rules = 3; + optional string mode_specific_context = 4; } message ErrorDetails { // aiserver.v1.ErrorDetails enum Error { // aiserver.v1.ErrorDetails.Error @@ -62,6 +213,8 @@ message ErrorDetails { // aiserver.v1.ErrorDetails ERROR_REPOSITORY_SERVICE_REPOSITORY_IS_NOT_INITIALIZED = 37; ERROR_UNAUTHORIZED = 38; ERROR_CONVERSATION_TOO_LONG = 43; + ERROR_USAGE_PRICING_REQUIRED = 44; + ERROR_USAGE_PRICING_REQUIRED_CHANGEABLE = 45; } Error error = 1; CustomErrorDetails details = 2; @@ -75,38 +228,50 @@ message CustomErrorDetails { // aiserver.v1.CustomErrorDetails optional bool show_request_id = 5; optional bool should_show_immediate_error = 6; } -message GetChatRequest { // aiserver.v1.GetChatRequest - CurrentFileInfo current_file = 1; - repeated ConversationMessage conversation = 2; - repeated RepositoryInfo repositories = 3; - ExplicitContext explicit_context = 4; - optional string workspace_root_path = 5; - repeated CodeBlock code_blocks = 6; - ModelDetails model_details = 7; - repeated string documentation_identifiers = 8; - string request_id = 9; - LinterErrors linter_errors = 10; - optional string summary = 11; - optional int32 summary_up_until_index = 12; - optional bool allow_long_file_scan = 13; - optional bool is_bash = 14; - string conversation_id = 15; - optional bool can_handle_filenames_after_language_ids = 16; - optional string use_web = 17; - repeated ChatQuote quotes = 18; - optional DebugInfo debug_info = 19; - optional string workspace_id = 20; - repeated ChatExternalLink external_links = 21; - repeated CommitNote commit_notes = 23; - optional bool long_context_mode = 22; - optional bool is_eval = 24; - optional int32 desired_max_tokens = 26; - ContextAST context_ast = 25; - optional bool is_composer = 27; - optional bool runnable_code_blocks = 28; - optional bool should_cache = 29; - optional bool allow_model_fallbacks = 30; - optional int32 number_of_times_shown_fallback_model_warning = 31; +message ImageProto { // aiserver.v1.ImageProto + message Dimension { // aiserver.v1.ImageProto.Dimension + int32 width = 1; + int32 height = 2; + } + bytes data = 1; + Dimension dimension = 2; +} +message ChatQuote { // aiserver.v1.ChatQuote + string markdown = 1; + string bubble_id = 2; + int32 section_index = 3; +} +message ChatExternalLink { // aiserver.v1.ChatExternalLink + string url = 1; + string uuid = 2; +} +message CommitNote { // aiserver.v1.CommitNote + string note = 1; + string commit_hash = 2; +} +message CodeChunk { // aiserver.v1.CodeChunk + enum Intent { // aiserver.v1.CodeChunk.Intent + INTENT_UNSPECIFIED = 0; + INTENT_COMPOSER_FILE = 1; + INTENT_COMPRESSED_COMPOSER_FILE = 2; + } + enum SummarizationStrategy { // aiserver.v1.CodeChunk.SummarizationStrategy + SUMMARIZATION_STRATEGY_NONE_UNSPECIFIED = 0; + SUMMARIZATION_STRATEGY_SUMMARIZED = 1; + SUMMARIZATION_STRATEGY_EMBEDDED = 2; + } + string relative_workspace_path = 1; + int32 start_line_number = 2; + repeated string lines = 3; + optional SummarizationStrategy summarization_strategy = 4; + string language_identifier = 5; + optional Intent intent = 6; + optional bool is_final_version = 7; + optional bool is_first_version = 8; +} +message CodeResult { // aiserver.v1.CodeResult + CodeBlock code_block = 1; + float score = 2; } message RepositoryInfo { // aiserver.v1.RepositoryInfo string relative_workspace_path = 1; @@ -119,163 +284,673 @@ message RepositoryInfo { // aiserver.v1.RepositoryInfo optional int32 num_files = 8; optional double orthogonal_transform_seed = 9; optional EmbeddingModel preferred_embedding_model = 10; + string workspace_uri = 11; } -enum EmbeddingModel { // aiserver.v1.EmbeddingModel - EMBEDDING_MODEL_UNSPECIFIED = 0; - EMBEDDING_MODEL_VOYAGE_CODE_2 = 1; - EMBEDDING_MODEL_TEXT_EMBEDDINGS_LARGE_3 = 2; - EMBEDDING_MODEL_QWEN_1_5B_CUSTOM = 3; +enum ClientSideToolV2 { // aiserver.v1.ClientSideToolV2 + CLIENT_SIDE_TOOL_V2_UNSPECIFIED = 0; + CLIENT_SIDE_TOOL_V2_READ_SEMSEARCH_FILES = 1; + CLIENT_SIDE_TOOL_V2_READ_FILE_FOR_IMPORTS = 2; + CLIENT_SIDE_TOOL_V2_RIPGREP_SEARCH = 3; + CLIENT_SIDE_TOOL_V2_RUN_TERMINAL_COMMAND = 4; + CLIENT_SIDE_TOOL_V2_READ_FILE = 5; + CLIENT_SIDE_TOOL_V2_LIST_DIR = 6; + CLIENT_SIDE_TOOL_V2_EDIT_FILE = 7; + CLIENT_SIDE_TOOL_V2_FILE_SEARCH = 8; + CLIENT_SIDE_TOOL_V2_SEMANTIC_SEARCH_FULL = 9; + CLIENT_SIDE_TOOL_V2_CREATE_FILE = 10; + CLIENT_SIDE_TOOL_V2_DELETE_FILE = 11; + CLIENT_SIDE_TOOL_V2_REAPPLY = 12; + CLIENT_SIDE_TOOL_V2_GET_RELATED_FILES = 13; + CLIENT_SIDE_TOOL_V2_PARALLEL_APPLY = 14; + CLIENT_SIDE_TOOL_V2_RUN_TERMINAL_COMMAND_V2 = 15; + CLIENT_SIDE_TOOL_V2_FETCH_RULES = 16; + CLIENT_SIDE_TOOL_V2_PLANNER = 17; + CLIENT_SIDE_TOOL_V2_WEB_SEARCH = 18; + CLIENT_SIDE_TOOL_V2_MCP = 19; + CLIENT_SIDE_TOOL_V2_WEB_VIEWER = 20; + CLIENT_SIDE_TOOL_V2_DIFF_HISTORY = 21; + CLIENT_SIDE_TOOL_V2_IMPLEMENTER = 22; + CLIENT_SIDE_TOOL_V2_SEARCH_SYMBOLS = 23; + CLIENT_SIDE_TOOL_V2_BACKGROUND_COMPOSER_FOLLOWUP = 24; } -message ModelDetails { // aiserver.v1.ModelDetails - optional string model_name = 1; - optional string api_key = 2; - optional bool enable_ghost_mode = 3; - optional AzureState azure_state = 4; - optional bool enable_slow_pool = 5; - optional string openai_api_base_url = 6; +enum RunTerminalCommandEndedReason { // aiserver.v1.RunTerminalCommandEndedReason + RUN_TERMINAL_COMMAND_ENDED_REASON_UNSPECIFIED = 0; + RUN_TERMINAL_COMMAND_ENDED_REASON_EXECUTION_COMPLETED = 1; + RUN_TERMINAL_COMMAND_ENDED_REASON_EXECUTION_ABORTED = 2; + RUN_TERMINAL_COMMAND_ENDED_REASON_EXECUTION_FAILED = 3; + RUN_TERMINAL_COMMAND_ENDED_REASON_ERROR_OCCURRED_CHECKING_REASON = 4; } -message AzureState { // aiserver.v1.AzureState - string api_key = 1; - string base_url = 2; - string deployment = 3; - bool use_azure = 4; +message ReapplyResult { // aiserver.v1.ReapplyResult + EditFileResult.FileDiff diff = 1; + bool is_applied = 2; + bool apply_failed = 3; + repeated LinterError linter_errors = 4; + optional bool rejected = 5; } -message LinterErrors { // aiserver.v1.LinterErrors - string relative_workspace_path = 1; - repeated LinterError errors = 2; - string file_contents = 3; +message FetchRulesResult { // aiserver.v1.FetchRulesResult + repeated CursorRule rules = 1; } -message LinterError { // aiserver.v1.LinterError - string message = 1; - CursorRange range = 2; - optional string source = 3; - repeated Diagnostic.RelatedInformation related_information = 4; - optional Diagnostic.DiagnosticSeverity severity = 5; +message PlannerResult { // aiserver.v1.PlannerResult + string plan = 1; } -message CursorRange { // aiserver.v1.CursorRange - CursorPosition start_position = 1; - CursorPosition end_position = 2; +message GetRelatedFilesResult { // aiserver.v1.GetRelatedFilesResult + message File { // aiserver.v1.GetRelatedFilesResult.File + string uri = 1; + float score = 2; + } + repeated File files = 1; } -message CursorPosition { // aiserver.v1.CursorPosition - int32 line = 1; - int32 column = 2; +message ToolResultError { // aiserver.v1.ToolResultError + string client_visible_error_message = 1; + string model_visible_error_message = 2; + optional string actual_error_message_only_send_from_client_to_server_never_the_other_way_around_because_that_may_be_a_security_risk = 3; } -message ExplicitContext { // aiserver.v1.ExplicitContext - string context = 1; - optional string repo_context = 2; - repeated CursorRule rules = 3; +message ClientSideToolV2Result { // aiserver.v1.ClientSideToolV2Result + ClientSideToolV2 tool = 1; + oneof result { + ReadSemsearchFilesResult read_semsearch_files_result = 2; + ReadFileForImportsResult read_file_for_imports_result = 3; + RipgrepSearchResult ripgrep_search_result = 4; + RunTerminalCommandResult run_terminal_command_result = 5; + ReadFileResult read_file_result = 6; + ListDirResult list_dir_result = 9; + EditFileResult edit_file_result = 10; + ToolCallFileSearchResult file_search_result = 11; + SemanticSearchFullResult semantic_search_full_result = 18; + CreateFileResult create_file_result = 19; + DeleteFileResult delete_file_result = 20; + ReapplyResult reapply_result = 21; + GetRelatedFilesResult get_related_files_result = 22; + ParallelApplyResult parallel_apply_result = 23; + RunTerminalCommandV2Result run_terminal_command_v2_result = 24; + FetchRulesResult fetch_rules_result = 25; + PlannerResult planner_result = 26; + WebSearchResult web_search_result = 27; + MCPResult mcp_result = 28; + WebViewerResult web_viewer_result = 29; + DiffHistoryResult diff_history_result = 30; + ImplementerResult implementer_result = 31; + SearchSymbolsResult search_symbols_result = 32; + BackgroundComposerFollowupResult background_composer_followup_result = 33; + } + optional ToolResultError error = 8; } -message CursorRule { // aiserver.v1.CursorRule - string name = 1; - string description = 2; - optional string body = 3; - optional bool is_from_glob = 4; +message EditFileResult { // aiserver.v1.EditFileResult + message FileDiff { // aiserver.v1.EditFileResult.FileDiff + enum Editor { // aiserver.v1.EditFileResult.FileDiff.Editor + EDITOR_UNSPECIFIED = 0; + EDITOR_AI = 1; + EDITOR_HUMAN = 2; + } + message ChunkDiff { // aiserver.v1.EditFileResult.FileDiff.ChunkDiff + string diff_string = 1; + int32 old_start = 2; + int32 new_start = 3; + int32 old_lines = 4; + int32 new_lines = 5; + int32 lines_removed = 6; + int32 lines_added = 7; + } + repeated ChunkDiff chunks = 1; + Editor editor = 2; + bool hit_timeout = 3; + } + FileDiff diff = 1; + bool is_applied = 2; + bool apply_failed = 3; + repeated LinterError linter_errors = 4; + optional bool rejected = 5; } -message DebugInfo { // aiserver.v1.DebugInfo - message Variable { // aiserver.v1.DebugInfo.Variable +message ToolCallFileSearchResult { // aiserver.v1.ToolCallFileSearchResult + message File { // aiserver.v1.ToolCallFileSearchResult.File + string uri = 1; + } + repeated File files = 1; + optional bool limit_hit = 2; + int32 num_results = 3; +} +message ListDirResult { // aiserver.v1.ListDirResult + message File { // aiserver.v1.ListDirResult.File string name = 1; - string value = 2; - optional string type = 3; + bool is_directory = 2; + optional int64 size = 3; + optional google.protobuf.Timestamp last_modified = 4; + optional int32 num_children = 5; + optional int32 num_lines = 6; } - message Scope { // aiserver.v1.DebugInfo.Scope - string name = 1; - repeated Variable variables = 2; - } - message CallStackFrame { // aiserver.v1.DebugInfo.CallStackFrame - string relative_workspace_path = 1; - int32 line_number = 2; - string function_name = 3; - repeated Scope scopes = 4; - } - message Breakpoint { // aiserver.v1.DebugInfo.Breakpoint - string relative_workspace_path = 1; - int32 line_number = 2; - repeated string lines_before_breakpoint = 3; - repeated string lines_after_breakpoint = 4; - optional string exception_info = 5; - } - Breakpoint breakpoint = 1; - repeated CallStackFrame call_stack = 2; - repeated CodeBlock history = 3; + repeated File files = 1; + string directory_relative_workspace_path = 2; } -message CodeBlock { // aiserver.v1.CodeBlock - message Signatures { // aiserver.v1.CodeBlock.Signatures - repeated CursorRange ranges = 1; +message ReadFileResult { // aiserver.v1.ReadFileResult + string contents = 1; + bool did_downgrade_to_line_range = 2; + bool did_shorten_line_range = 3; + bool did_set_default_line_range = 4; + optional string full_file_contents = 5; + optional string outline = 6; + optional int32 start_line_one_indexed = 7; + optional int32 end_line_one_indexed_inclusive = 8; + string relative_workspace_path = 9; + bool did_shorten_char_range = 10; +} +message RipgrepSearchResult { // aiserver.v1.RipgrepSearchResult + RipgrepSearchResultInternal internal = 1; +} +message RipgrepSearchResultInternal { // aiserver.v1.RipgrepSearchResultInternal + enum TextSearchCompleteMessageType { // aiserver.v1.RipgrepSearchResultInternal.TextSearchCompleteMessageType + TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_UNSPECIFIED = 0; + TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_INFORMATION = 1; + TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_WARNING = 2; + } + enum SearchCompletionExitCode { // aiserver.v1.RipgrepSearchResultInternal.SearchCompletionExitCode + SEARCH_COMPLETION_EXIT_CODE_UNSPECIFIED = 0; + SEARCH_COMPLETION_EXIT_CODE_NORMAL = 1; + SEARCH_COMPLETION_EXIT_CODE_NEW_SEARCH_STARTED = 2; + } + message IFileMatch { // aiserver.v1.RipgrepSearchResultInternal.IFileMatch + string resource = 1; + repeated ITextSearchResult results = 2; + } + message ITextSearchResult { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchResult + oneof result { + ITextSearchMatch match = 1; + ITextSearchContext context = 2; + } + } + message ITextSearchMatch { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchMatch + optional string uri = 1; + repeated ISearchRangeSetPairing range_locations = 2; + string preview_text = 3; + optional int32 webview_index = 4; + optional string cell_fragment = 5; + } + message ITextSearchContext { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchContext + optional string uri = 1; + string text = 2; + int32 line_number = 3; + } + message ISearchRangeSetPairing { // aiserver.v1.RipgrepSearchResultInternal.ISearchRangeSetPairing + ISearchRange source = 1; + ISearchRange preview = 2; + } + message ISearchRange { // aiserver.v1.RipgrepSearchResultInternal.ISearchRange + int32 start_line_number = 1; + int32 start_column = 2; + int32 end_line_number = 3; + int32 end_column = 4; + } + message ITextSearchCompleteMessage { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchCompleteMessage + string text = 1; + TextSearchCompleteMessageType type = 2; + optional bool trusted = 3; + } + message IFileSearchStats { // aiserver.v1.RipgrepSearchResultInternal.IFileSearchStats + enum FileSearchProviderType { // aiserver.v1.RipgrepSearchResultInternal.IFileSearchStats.FileSearchProviderType + FILE_SEARCH_PROVIDER_TYPE_UNSPECIFIED = 0; + FILE_SEARCH_PROVIDER_TYPE_FILE_SEARCH_PROVIDER = 1; + FILE_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS = 2; + } + bool from_cache = 1; + oneof detail_stats { + ISearchEngineStats search_engine_stats = 2; + ICachedSearchStats cached_search_stats = 3; + IFileSearchProviderStats file_search_provider_stats = 4; + } + int32 result_count = 5; + FileSearchProviderType type = 6; + optional int32 sorting_time = 7; + } + message ITextSearchStats { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchStats + enum TextSearchProviderType { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchStats.TextSearchProviderType + TEXT_SEARCH_PROVIDER_TYPE_UNSPECIFIED = 0; + TEXT_SEARCH_PROVIDER_TYPE_TEXT_SEARCH_PROVIDER = 1; + TEXT_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS = 2; + TEXT_SEARCH_PROVIDER_TYPE_AI_TEXT_SEARCH_PROVIDER = 3; + } + TextSearchProviderType type = 1; + } + message ISearchEngineStats { // aiserver.v1.RipgrepSearchResultInternal.ISearchEngineStats + int32 file_walk_time = 1; + int32 directories_walked = 2; + int32 files_walked = 3; + int32 cmd_time = 4; + optional int32 cmd_result_count = 5; + } + message ICachedSearchStats { // aiserver.v1.RipgrepSearchResultInternal.ICachedSearchStats + bool cache_was_resolved = 1; + int32 cache_lookup_time = 2; + int32 cache_filter_time = 3; + int32 cache_entry_count = 4; + } + message IFileSearchProviderStats { // aiserver.v1.RipgrepSearchResultInternal.IFileSearchProviderStats + int32 provider_time = 1; + int32 post_process_time = 2; + } + repeated IFileMatch results = 1; + optional SearchCompletionExitCode exit = 2; + optional bool limit_hit = 3; + repeated ITextSearchCompleteMessage messages = 4; + oneof stats { + IFileSearchStats file_search_stats = 5; + ITextSearchStats text_search_stats = 6; + } +} +message MissingFile { // aiserver.v1.MissingFile + enum MissingReason { // aiserver.v1.MissingFile.MissingReason + MISSING_REASON_UNSPECIFIED = 0; + MISSING_REASON_TOO_LARGE = 1; + MISSING_REASON_NOT_FOUND = 2; } string relative_workspace_path = 1; - optional string file_contents = 2; - optional int32 file_contents_length = 9; - CursorRange range = 3; - string contents = 4; - Signatures signatures = 5; - optional string override_contents = 6; - optional string original_contents = 7; - repeated DetailedLine detailed_lines = 8; + MissingReason missing_reason = 2; + optional int32 num_lines = 3; } -message DetailedLine { // aiserver.v1.DetailedLine - string text = 1; - float line_number = 2; - bool is_signature = 3; +message ReadSemsearchFilesResult { // aiserver.v1.ReadSemsearchFilesResult + repeated CodeResult code_results = 1; + repeated File all_files = 2; + repeated MissingFile missing_files = 3; } -message CurrentFileInfo { // aiserver.v1.CurrentFileInfo - message NotebookCell { // aiserver.v1.CurrentFileInfo.NotebookCell - } - string relative_workspace_path = 1; - string contents = 2; - bool rely_on_filesync = 18; - optional string sha_256_hash = 17; - repeated NotebookCell cells = 16; - repeated BM25Chunk top_chunks = 10; - int32 contents_start_at_line = 9; - CursorPosition cursor_position = 3; - repeated DataframeInfo dataframes = 4; - int32 total_number_of_lines = 8; - string language_id = 5; - CursorRange selection = 6; - optional int32 alternative_version_id = 11; - repeated Diagnostic diagnostics = 7; - optional int32 file_version = 14; - repeated int32 cell_start_lines = 15; - string workspace_root_path = 19; +message SemanticSearchFullResult { // aiserver.v1.SemanticSearchFullResult + repeated CodeResult code_results = 1; + repeated File all_files = 2; + repeated MissingFile missing_files = 3; } -message Diagnostic { // aiserver.v1.Diagnostic - enum DiagnosticSeverity { // aiserver.v1.Diagnostic.DiagnosticSeverity - DIAGNOSTIC_SEVERITY_UNSPECIFIED = 0; - DIAGNOSTIC_SEVERITY_ERROR = 1; - DIAGNOSTIC_SEVERITY_WARNING = 2; - DIAGNOSTIC_SEVERITY_INFORMATION = 3; - DIAGNOSTIC_SEVERITY_HINT = 4; - } - message RelatedInformation { // aiserver.v1.Diagnostic.RelatedInformation - string message = 1; - CursorRange range = 2; - } - string message = 1; - CursorRange range = 2; - DiagnosticSeverity severity = 3; - repeated RelatedInformation related_information = 4; +message ReadFileForImportsResult { // aiserver.v1.ReadFileForImportsResult + string contents = 1; } -message DataframeInfo { // aiserver.v1.DataframeInfo - message Column { // aiserver.v1.DataframeInfo.Column - string key = 1; - string type = 2; - } - string name = 1; - string shape = 2; - int32 data_dimensionality = 3; - repeated Column columns = 6; - int32 row_count = 7; - string index_column = 8; +message CreateFileResult { // aiserver.v1.CreateFileResult + bool file_created_successfully = 1; + bool file_already_exists = 2; } -message BM25Chunk { // aiserver.v1.BM25Chunk - string content = 1; - SimplestRange range = 2; - int32 score = 3; - string relative_path = 4; +message DeleteFileResult { // aiserver.v1.DeleteFileResult + bool rejected = 1; + bool file_non_existent = 2; + bool file_deleted_successfully = 3; } -message SimplestRange { // aiserver.v1.SimplestRange +message RunTerminalCommandResult { // aiserver.v1.RunTerminalCommandResult + string output = 1; + int32 exit_code = 2; + optional bool rejected = 3; + bool popped_out_into_background = 4; +} +message Range { // aiserver.v1.Range int32 start_line = 1; - int32 end_line_inclusive = 2; + int32 start_character = 2; + int32 end_line = 3; + int32 end_character = 4; +} +message MatchRange { // aiserver.v1.MatchRange + int32 start = 1; + int32 end = 2; +} +message ParallelApplyResult { // aiserver.v1.ParallelApplyResult + message FileResult { // aiserver.v1.ParallelApplyResult.FileResult + string file_path = 1; + EditFileResult.FileDiff diff = 2; + bool is_applied = 3; + bool apply_failed = 4; + optional string error = 5; + repeated LinterError linter_errors = 6; + } + repeated FileResult file_results = 1; + optional string error = 2; + optional bool rejected = 3; +} +message RunTerminalCommandV2Result { // aiserver.v1.RunTerminalCommandV2Result + string output = 1; + int32 exit_code = 2; + optional bool rejected = 3; + bool popped_out_into_background = 4; + bool is_running_in_background = 5; + bool not_interrupted = 6; + string resulting_working_directory = 7; + bool did_user_change = 8; + RunTerminalCommandEndedReason ended_reason = 9; + optional int32 exit_code_v2 = 10; +} +message WebSearchResult { // aiserver.v1.WebSearchResult + message WebReference { // aiserver.v1.WebSearchResult.WebReference + string title = 1; + string url = 2; + string chunk = 3; + } + repeated WebReference references = 1; + optional bool is_final = 2; + optional bool rejected = 3; +} +message WebViewerResult { // aiserver.v1.WebViewerResult + message ConsoleLog { // aiserver.v1.WebViewerResult.ConsoleLog + string type = 1; + string text = 2; + string source = 3; + } + string url = 1; + ImageProto screenshot = 2; + repeated ImageProto screenshots = 3; + repeated ConsoleLog console_logs = 4; +} +message MCPResult { // aiserver.v1.MCPResult + string selected_tool = 1; + string result = 2; +} +message DiffHistoryResult { // aiserver.v1.DiffHistoryResult + message RenderedDiff { // aiserver.v1.DiffHistoryResult.RenderedDiff + int32 start_line_number = 1; + int32 end_line_number_exclusive = 2; + repeated string before_context_lines = 3; + repeated string removed_lines = 4; + repeated string added_lines = 5; + repeated string after_context_lines = 6; + } + message HumanChange { // aiserver.v1.DiffHistoryResult.HumanChange + string relative_workspace_path = 1; + repeated RenderedDiff rendered_diffs = 2; + } + repeated HumanChange human_changes = 40; +} +message ImplementerResult { // aiserver.v1.ImplementerResult + message FileDiff { // aiserver.v1.ImplementerResult.FileDiff + enum Editor { // aiserver.v1.ImplementerResult.FileDiff.Editor + EDITOR_UNSPECIFIED = 0; + EDITOR_AI = 1; + EDITOR_HUMAN = 2; + } + message ChunkDiff { // aiserver.v1.ImplementerResult.FileDiff.ChunkDiff + string diff_string = 1; + int32 old_start = 2; + int32 new_start = 3; + int32 old_lines = 4; + int32 new_lines = 5; + int32 lines_removed = 6; + int32 lines_added = 7; + } + repeated ChunkDiff chunks = 1; + Editor editor = 2; + bool hit_timeout = 3; + } + EditFileResult.FileDiff diff = 1; + bool is_applied = 2; + bool apply_failed = 3; + repeated LinterError linter_errors = 4; +} +message SearchSymbolsResult { // aiserver.v1.SearchSymbolsResult + message SymbolMatch { // aiserver.v1.SearchSymbolsResult.SymbolMatch + string name = 1; + string uri = 2; + Range range = 3; + string secondary_text = 4; + repeated MatchRange label_matches = 5; + repeated MatchRange description_matches = 6; + double score = 7; + } + repeated SymbolMatch matches = 1; + optional bool rejected = 2; +} +message BackgroundComposerFollowupResult { // aiserver.v1.BackgroundComposerFollowupResult + string proposed_followup = 1; + bool is_sent = 2; +} +message GetLintsForChangeResponse { // aiserver.v1.GetLintsForChangeResponse + message Lint { // aiserver.v1.GetLintsForChangeResponse.Lint + message QuickFix { // aiserver.v1.GetLintsForChangeResponse.Lint.QuickFix + message Edit { // aiserver.v1.GetLintsForChangeResponse.Lint.QuickFix.Edit + string relative_workspace_path = 1; + string text = 2; + int32 start_line_number_one_indexed = 3; + int32 start_column_one_indexed = 4; + int32 end_line_number_inclusive_one_indexed = 5; + int32 end_column_one_indexed = 6; + } + string message = 1; + string kind = 2; + bool is_preferred = 3; + repeated Edit edits = 4; + } + string message = 1; + string severity = 2; + string relative_workspace_path = 3; + int32 start_line_number_one_indexed = 4; + int32 start_column_one_indexed = 5; + int32 end_line_number_inclusive_one_indexed = 6; + int32 end_column_one_indexed = 7; + repeated QuickFix quick_fixes = 9; + } + repeated Lint lints = 1; +} +message DocumentationChunk { // aiserver.v1.DocumentationChunk + string doc_name = 1; + string page_url = 2; + string documentation_chunk = 3; + float score = 4; + string page_title = 5; +} +message ComposerCapabilityRequest { // aiserver.v1.ComposerCapabilityRequest + enum ComposerCapabilityType { // aiserver.v1.ComposerCapabilityRequest.ComposerCapabilityType + COMPOSER_CAPABILITY_TYPE_UNSPECIFIED = 0; + COMPOSER_CAPABILITY_TYPE_LOOP_ON_LINTS = 1; + COMPOSER_CAPABILITY_TYPE_LOOP_ON_TESTS = 2; + COMPOSER_CAPABILITY_TYPE_MEGA_PLANNER = 3; + COMPOSER_CAPABILITY_TYPE_LOOP_ON_COMMAND = 4; + COMPOSER_CAPABILITY_TYPE_TOOL_CALL = 5; + COMPOSER_CAPABILITY_TYPE_DIFF_REVIEW = 6; + COMPOSER_CAPABILITY_TYPE_CONTEXT_PICKING = 7; + COMPOSER_CAPABILITY_TYPE_EDIT_TRAIL = 8; + COMPOSER_CAPABILITY_TYPE_AUTO_CONTEXT = 9; + COMPOSER_CAPABILITY_TYPE_CONTEXT_PLANNER = 10; + COMPOSER_CAPABILITY_TYPE_DIFF_HISTORY = 11; + COMPOSER_CAPABILITY_TYPE_REMEMBER_THIS = 12; + COMPOSER_CAPABILITY_TYPE_DECOMPOSER = 13; + COMPOSER_CAPABILITY_TYPE_USES_CODEBASE = 14; + COMPOSER_CAPABILITY_TYPE_TOOL_FORMER = 15; + COMPOSER_CAPABILITY_TYPE_CURSOR_RULES = 16; + COMPOSER_CAPABILITY_TYPE_TOKEN_COUNTER = 17; + COMPOSER_CAPABILITY_TYPE_USAGE_DATA = 18; + COMPOSER_CAPABILITY_TYPE_CHIMES = 19; + COMPOSER_CAPABILITY_TYPE_CODE_DECAY_TRACKER = 20; + COMPOSER_CAPABILITY_TYPE_BACKGROUND_COMPOSER = 21; + COMPOSER_CAPABILITY_TYPE_SUMMARIZATION = 22; + } + enum ToolType { // aiserver.v1.ComposerCapabilityRequest.ToolType + TOOL_TYPE_UNSPECIFIED = 0; + TOOL_TYPE_ADD_FILE_TO_CONTEXT = 1; + TOOL_TYPE_RUN_TERMINAL_COMMAND = 2; + TOOL_TYPE_ITERATE = 3; + TOOL_TYPE_REMOVE_FILE_FROM_CONTEXT = 4; + TOOL_TYPE_SEMANTIC_SEARCH_CODEBASE = 5; + } + message ToolSchema { // aiserver.v1.ComposerCapabilityRequest.ToolSchema + ToolType type = 1; + string name = 2; + map properties = 3; + repeated string required = 4; + } + message SchemaProperty { // aiserver.v1.ComposerCapabilityRequest.SchemaProperty + string type = 1; + optional string description = 2; + } + message LoopOnLintsCapability { // aiserver.v1.ComposerCapabilityRequest.LoopOnLintsCapability + repeated LinterErrors linter_errors = 1; + optional string custom_instructions = 2; + } + message LoopOnTestsCapability { // aiserver.v1.ComposerCapabilityRequest.LoopOnTestsCapability + repeated string test_names = 1; + optional string custom_instructions = 2; + } + message MegaPlannerCapability { // aiserver.v1.ComposerCapabilityRequest.MegaPlannerCapability + optional string custom_instructions = 1; + } + message LoopOnCommandCapability { // aiserver.v1.ComposerCapabilityRequest.LoopOnCommandCapability + string command = 1; + optional string custom_instructions = 2; + optional string output = 3; + optional int32 exit_code = 4; + } + message ToolCallCapability { // aiserver.v1.ComposerCapabilityRequest.ToolCallCapability + optional string custom_instructions = 1; + repeated ToolSchema tool_schemas = 2; + repeated string relevant_files = 3; + repeated string files_in_context = 4; + repeated string semantic_search_files = 5; + } + message DiffReviewCapability { // aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability + message SimpleFileDiff { // aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability.SimpleFileDiff + message Chunk { // aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability.SimpleFileDiff.Chunk + repeated string old_lines = 1; + repeated string new_lines = 2; + LineRange old_range = 3; + LineRange new_range = 4; + } + string relative_workspace_path = 1; + repeated Chunk chunks = 3; + } + optional string custom_instructions = 1; + repeated SimpleFileDiff diffs = 2; + } + message DecomposerCapability { // aiserver.v1.ComposerCapabilityRequest.DecomposerCapability + optional string custom_instructions = 1; + } + message ContextPickingCapability { // aiserver.v1.ComposerCapabilityRequest.ContextPickingCapability + optional string custom_instructions = 1; + repeated string potential_context_files = 2; + repeated CodeChunk potential_context_code_chunks = 3; + repeated string files_in_context = 4; + } + message EditTrailCapability { // aiserver.v1.ComposerCapabilityRequest.EditTrailCapability + optional string custom_instructions = 1; + } + message AutoContextCapability { // aiserver.v1.ComposerCapabilityRequest.AutoContextCapability + optional string custom_instructions = 1; + repeated string additional_files = 2; + } + message ContextPlannerCapability { // aiserver.v1.ComposerCapabilityRequest.ContextPlannerCapability + optional string custom_instructions = 1; + repeated CodeChunk attached_code_chunks = 2; + } + message RememberThisCapability { // aiserver.v1.ComposerCapabilityRequest.RememberThisCapability + optional string custom_instructions = 1; + string memory = 2; + } + message CursorRulesCapability { // aiserver.v1.ComposerCapabilityRequest.CursorRulesCapability + optional string custom_instructions = 1; + } + ComposerCapabilityType type = 1; + oneof data { + LoopOnLintsCapability loop_on_lints = 2; + LoopOnTestsCapability loop_on_tests = 3; + MegaPlannerCapability mega_planner = 4; + LoopOnCommandCapability loop_on_command = 5; + ToolCallCapability tool_call = 6; + DiffReviewCapability diff_review = 7; + ContextPickingCapability context_picking = 8; + EditTrailCapability edit_trail = 9; + AutoContextCapability auto_context = 10; + ContextPlannerCapability context_planner = 11; + RememberThisCapability remember_this = 12; + DecomposerCapability decomposer = 13; + CursorRulesCapability cursor_rules = 14; + } +} +enum ChunkType { // aiserver.v1.ChunkType + CHUNK_TYPE_UNSPECIFIED = 0; + CHUNK_TYPE_CODEBASE = 1; + CHUNK_TYPE_LONG_FILE = 2; + CHUNK_TYPE_DOCS = 3; +} +message ConversationSummary { // aiserver.v1.ConversationSummary + string summary = 1; + string truncation_last_bubble_id_inclusive = 2; + string client_should_start_sending_from_inclusive_bubble_id = 3; + string previous_conversation_summary_bubble_id = 4; + bool includes_tool_results = 5; +} +message DocumentationCitation { // aiserver.v1.DocumentationCitation + repeated DocumentationChunk chunks = 1; +} +message WebCitation { // aiserver.v1.WebCitation + repeated WebReference references = 1; +} +message WebReference { // aiserver.v1.WebReference + string title = 2; + string url = 1; + string chunk = 3; +} +message DocsReference { // aiserver.v1.DocsReference + string title = 1; + string url = 2; + string chunk = 3; + string name = 4; +} +message StatusUpdate { // aiserver.v1.StatusUpdate + string message = 1; + optional string metadata = 2; +} +message StatusUpdates { // aiserver.v1.StatusUpdates + repeated StatusUpdate updates = 1; +} +message ComposerFileDiffHistory { // aiserver.v1.ComposerFileDiffHistory + string file_name = 1; + repeated string diff_history = 2; + repeated double diff_history_timestamps = 3; +} +message StreamUnifiedChatRequest { // aiserver.v1.StreamUnifiedChatRequest + enum UnifiedMode { // aiserver.v1.StreamUnifiedChatRequest.UnifiedMode + UNIFIED_MODE_UNSPECIFIED = 0; + UNIFIED_MODE_CHAT = 1; + UNIFIED_MODE_AGENT = 2; + UNIFIED_MODE_EDIT = 3; + UNIFIED_MODE_CUSTOM = 4; + } +} +message ContextPiece { // aiserver.v1.ContextPiece + string relative_workspace_path = 1; + string content = 2; + float score = 3; +} +message ServiceStatusUpdate { // aiserver.v1.ServiceStatusUpdate + string message = 1; + string codicon = 2; + optional bool allow_command_links_potentially_unsafe_please_only_use_for_handwritten_trusted_markdown = 3; + optional string action_to_run_on_status_update = 4; +} +message SymbolLink { // aiserver.v1.SymbolLink + string symbol_name = 1; + string symbol_search_string = 2; + string relative_workspace_path = 3; + int32 rough_line_number = 4; +} +message FileLink { // aiserver.v1.FileLink + string display_name = 1; + string relative_workspace_path = 2; +} +message RedDiff { // aiserver.v1.RedDiff + string relative_workspace_path = 1; + repeated SimplestRange red_ranges = 2; + repeated SimplestRange red_ranges_reversed = 3; + string start_hash = 4; + string end_hash = 5; +} +message DiffFile { // aiserver.v1.DiffFile + string file_details = 1; + string file_name = 2; +} +message ViewableCommitProps { // aiserver.v1.ViewableCommitProps + string description = 1; + string message = 2; + repeated DiffFile files = 3; +} +message ViewablePRProps { // aiserver.v1.ViewablePRProps + string title = 1; + string body = 2; + repeated DiffFile files = 3; +} +message ViewableDiffProps { // aiserver.v1.ViewableDiffProps + repeated DiffFile files = 1; + string diff_preface = 2; +} +message ViewableGitContext { // aiserver.v1.ViewableGitContext + optional ViewableCommitProps commit_data = 1; + optional ViewablePRProps pull_request_data = 2; + repeated ViewableDiffProps diff_data = 3; } message ConversationMessage { // aiserver.v1.ConversationMessage enum MessageType { // aiserver.v1.ConversationMessage.MessageType @@ -383,6 +1058,21 @@ message ConversationMessage { // aiserver.v1.ConversationMessage string relative_workspace_path = 1; repeated RenderedDiff rendered_diffs = 2; } + message Thinking { // aiserver.v1.ConversationMessage.Thinking + string text = 1; + string signature = 2; + string redacted_thinking = 3; + } + message DiffSinceLastApply { // aiserver.v1.ConversationMessage.DiffSinceLastApply + string relative_workspace_path = 1; + optional EditFileResult.FileDiff diff = 2; + optional bool is_accepted = 4; + optional bool is_rejected = 5; + optional int32 last_apply_chained_from_n_human_messages_ago = 6; + } + message DeletedFile { // aiserver.v1.ConversationMessage.DeletedFile + string relative_workspace_path = 1; + } string text = 1; MessageType type = 2; repeated CodeChunk attached_code_chunks = 3; @@ -426,463 +1116,20 @@ message ConversationMessage { // aiserver.v1.ConversationMessage bool attached_human_changes = 41; repeated ComposerContext summarized_composers = 42; repeated CursorRule cursor_rules = 43; + repeated ContextPiece context_pieces = 44; + optional Thinking thinking = 45; + repeated Thinking all_thinking_blocks = 46; + optional StreamUnifiedChatRequest.UnifiedMode unified_mode = 47; + repeated DiffSinceLastApply diffs_since_last_apply = 48; + repeated DeletedFile deleted_files = 49; + optional string usage_uuid = 50; + repeated ClientSideToolV2 supported_tools = 51; + optional CurrentFileLocationData current_file_location_data = 52; } -message WebReference { // aiserver.v1.WebReference - string title = 2; - string url = 1; - string chunk = 3; -} -message ViewableGitContext { // aiserver.v1.ViewableGitContext - optional ViewableCommitProps commit_data = 1; - optional ViewablePRProps pull_request_data = 2; - repeated ViewableDiffProps diff_data = 3; -} -message ViewablePRProps { // aiserver.v1.ViewablePRProps - string title = 1; - string body = 2; - repeated DiffFile files = 3; -} -message DiffFile { // aiserver.v1.DiffFile - string file_details = 1; - string file_name = 2; -} -message ViewableDiffProps { // aiserver.v1.ViewableDiffProps - repeated DiffFile files = 1; - string diff_preface = 2; -} -message ViewableCommitProps { // aiserver.v1.ViewableCommitProps - string description = 1; - string message = 2; - repeated DiffFile files = 3; -} -message UserResponseToSuggestedCodeBlock { // aiserver.v1.UserResponseToSuggestedCodeBlock - enum UserResponseType { // aiserver.v1.UserResponseToSuggestedCodeBlock.UserResponseType - USER_RESPONSE_TYPE_UNSPECIFIED = 0; - USER_RESPONSE_TYPE_ACCEPT = 1; - USER_RESPONSE_TYPE_REJECT = 2; - USER_RESPONSE_TYPE_MODIFY = 3; - } - UserResponseType user_response_type = 1; - string file_path = 2; - optional FileDiff user_modifications_to_suggested_code_blocks = 3; -} -message FileDiff { // aiserver.v1.FileDiff - message Chunk { // aiserver.v1.FileDiff.Chunk - string content = 1; - repeated string lines = 2; - int32 old_start = 3; - int32 old_lines = 4; - int32 new_start = 5; - int32 new_lines = 6; - } - string from = 1; - string to = 2; - repeated Chunk chunks = 3; -} -message ToolResultError { // aiserver.v1.ToolResultError - string client_visible_error_message = 1; - string model_visible_error_message = 2; - optional string actual_error_message_only_send_from_client_to_server_never_the_other_way_around_because_that_may_be_a_security_risk = 3; -} -message ToolResult { // aiserver.v1.ToolResult - oneof tool_result { - BuiltinToolResult builtin_tool_result = 1; - CustomToolResult custom_tool_result = 2; - ErrorToolResult error_tool_result = 3; - } -} -message ErrorToolResult { // aiserver.v1.ErrorToolResult - string error_message = 1; -} -message CustomToolResult { // aiserver.v1.CustomToolResult - string tool_id = 1; - string result = 2; -} -message BuiltinToolResult { // aiserver.v1.BuiltinToolResult - BuiltinTool tool = 1; - oneof result { - SearchResult search_result = 2; - ReadChunkResult read_chunk_result = 3; - GotodefResult gotodef_result = 4; - EditResult edit_result = 5; - UndoEditResult undo_edit_result = 6; - EndResult end_result = 7; - NewFileResult new_file_result = 8; - AddTestResult add_test_result = 9; - RunTestResult run_test_result = 10; - DeleteTestResult delete_test_result = 11; - SaveFileResult save_file_result = 12; - GetTestsResult get_tests_result = 13; - GetSymbolsResult get_symbols_result = 14; - SemanticSearchResult semantic_search_result = 15; - GetProjectStructureResult get_project_structure_result = 16; - CreateRmFilesResult create_rm_files_result = 17; - RunTerminalCommandsResult run_terminal_commands_result = 18; - NewEditResult new_edit_result = 19; - ReadWithLinterResult read_with_linter_result = 20; - AddUiStepResult add_ui_step_result = 21; - ReadSemsearchFilesResult read_semsearch_files_result = 22; - CreateFileResult create_file_result = 23; - DeleteFileResult delete_file_result = 24; - } -} -enum BuiltinTool { // aiserver.v1.BuiltinTool - BUILTIN_TOOL_UNSPECIFIED = 0; - BUILTIN_TOOL_SEARCH = 1; - BUILTIN_TOOL_READ_CHUNK = 2; - BUILTIN_TOOL_GOTODEF = 3; - BUILTIN_TOOL_EDIT = 4; - BUILTIN_TOOL_UNDO_EDIT = 5; - BUILTIN_TOOL_END = 6; - BUILTIN_TOOL_NEW_FILE = 7; - BUILTIN_TOOL_ADD_TEST = 8; - BUILTIN_TOOL_RUN_TEST = 9; - BUILTIN_TOOL_DELETE_TEST = 10; - BUILTIN_TOOL_SAVE_FILE = 11; - BUILTIN_TOOL_GET_TESTS = 12; - BUILTIN_TOOL_GET_SYMBOLS = 13; - BUILTIN_TOOL_SEMANTIC_SEARCH = 14; - BUILTIN_TOOL_GET_PROJECT_STRUCTURE = 15; - BUILTIN_TOOL_CREATE_RM_FILES = 16; - BUILTIN_TOOL_RUN_TERMINAL_COMMANDS = 17; - BUILTIN_TOOL_NEW_EDIT = 18; - BUILTIN_TOOL_READ_WITH_LINTER = 19; -} -message UndoEditResult { // aiserver.v1.UndoEditResult - repeated string feedback = 1; - string relative_workspace_path = 4; - int32 context_start_line_number = 2; - repeated string context_lines = 3; - int32 context_total_num_lines = 5; - int32 file_total_lines = 6; -} -message SemanticSearchResult { // aiserver.v1.SemanticSearchResult - message Item { // aiserver.v1.SemanticSearchResult.Item - string relative_workspace_path = 1; - float score = 2; - string content = 3; - SimpleRange range = 4; - optional string original_content = 5; - repeated DetailedLine detailed_lines = 6; - } - repeated Item results = 1; - map files = 2; -} -message SimpleRange { // aiserver.v1.SimpleRange - int32 start_line_number = 1; - int32 start_column = 2; - int32 end_line_number_inclusive = 3; - int32 end_column = 4; -} -message SearchResult { // aiserver.v1.SearchResult - repeated SearchToolFileSearchResult file_results = 1; - int32 num_total_matches = 2; - int32 num_total_matched_files = 3; - bool num_total_may_be_incomplete = 4; - bool files_only = 5; -} -message SearchToolFileSearchResult { // aiserver.v1.SearchToolFileSearchResult - message Line { // aiserver.v1.SearchToolFileSearchResult.Line - int32 line_number = 1; - string text = 2; - } +message CurrentFileLocationData { // aiserver.v1.CurrentFileLocationData string relative_workspace_path = 1; - int32 num_matches = 2; - repeated Line potentially_relevant_lines = 3; - bool cropped = 4; -} -message SaveFileResult { // aiserver.v1.SaveFileResult -} -message RunTestResult { // aiserver.v1.RunTestResult - string result = 1; -} -message RunTerminalCommandsResult { // aiserver.v1.RunTerminalCommandsResult - repeated string outputs = 1; -} -message ReadWithLinterResult { // aiserver.v1.ReadWithLinterResult - string contents = 1; - repeated Diagnostic diagnostics = 2; -} -message ReadSemsearchFilesResult { // aiserver.v1.ReadSemsearchFilesResult - repeated CodeResult code_results = 1; - repeated File all_files = 2; - repeated MissingFile missing_files = 3; -} -message MissingFile { // aiserver.v1.MissingFile - enum MissingReason { // aiserver.v1.MissingFile.MissingReason - MISSING_REASON_UNSPECIFIED = 0; - MISSING_REASON_TOO_LARGE = 1; - MISSING_REASON_NOT_FOUND = 2; - } - string relative_workspace_path = 1; - MissingReason missing_reason = 2; - optional int32 num_lines = 3; -} -message File { // aiserver.v1.File - string relative_workspace_path = 1; - string contents = 2; -} -message CodeResult { // aiserver.v1.CodeResult - CodeBlock code_block = 1; - float score = 2; -} -message ReadChunkResult { // aiserver.v1.ReadChunkResult - string relative_workspace_path = 1; - int32 start_line_number = 2; - repeated string lines = 3; - int32 total_num_lines = 4; - bool cropped = 5; -} -message NewFileResult { // aiserver.v1.NewFileResult - string relative_workspace_path = 1; - int32 file_total_lines = 2; -} -message NewEditResult { // aiserver.v1.NewEditResult -} -message GotodefResult { // aiserver.v1.GotodefResult - repeated GotodefToolFileSearchResult results = 1; -} -message GotodefToolFileSearchResult { // aiserver.v1.GotodefToolFileSearchResult - message Line { // aiserver.v1.GotodefToolFileSearchResult.Line - int32 line_number = 1; - string text = 2; - } - string relative_workspace_path = 1; - repeated Line potentially_relevant_lines = 3; -} -message GetTestsResult { // aiserver.v1.GetTestsResult - message Test { // aiserver.v1.GetTestsResult.Test - string name = 1; - repeated string lines = 2; - } - repeated Test tests = 1; -} -message GetSymbolsResult { // aiserver.v1.GetSymbolsResult - repeated DocumentSymbol symbols = 1; -} -message DocumentSymbol { // aiserver.v1.DocumentSymbol - enum SymbolKind { // aiserver.v1.DocumentSymbol.SymbolKind - SYMBOL_KIND_UNSPECIFIED = 0; - SYMBOL_KIND_FILE = 1; - SYMBOL_KIND_MODULE = 2; - SYMBOL_KIND_NAMESPACE = 3; - SYMBOL_KIND_PACKAGE = 4; - SYMBOL_KIND_CLASS = 5; - SYMBOL_KIND_METHOD = 6; - SYMBOL_KIND_PROPERTY = 7; - SYMBOL_KIND_FIELD = 8; - SYMBOL_KIND_CONSTRUCTOR = 9; - SYMBOL_KIND_ENUM = 10; - SYMBOL_KIND_INTERFACE = 11; - SYMBOL_KIND_FUNCTION = 12; - SYMBOL_KIND_VARIABLE = 13; - SYMBOL_KIND_CONSTANT = 14; - SYMBOL_KIND_STRING = 15; - SYMBOL_KIND_NUMBER = 16; - SYMBOL_KIND_BOOLEAN = 17; - SYMBOL_KIND_ARRAY = 18; - SYMBOL_KIND_OBJECT = 19; - SYMBOL_KIND_KEY = 20; - SYMBOL_KIND_NULL = 21; - SYMBOL_KIND_ENUM_MEMBER = 22; - SYMBOL_KIND_STRUCT = 23; - SYMBOL_KIND_EVENT = 24; - SYMBOL_KIND_OPERATOR = 25; - SYMBOL_KIND_TYPE_PARAMETER = 26; - } - message Range { // aiserver.v1.DocumentSymbol.Range - int32 start_line_number = 1; - int32 start_column = 2; - int32 end_line_number = 3; - int32 end_column = 4; - } - string name = 1; - string detail = 2; - SymbolKind kind = 3; - string container_name = 5; - Range range = 6; - Range selection_range = 7; - repeated DocumentSymbol children = 8; -} -message GetProjectStructureResult { // aiserver.v1.GetProjectStructureResult - message File { // aiserver.v1.GetProjectStructureResult.File - string relative_workspace_path = 1; - string outline = 2; - } - repeated File files = 1; - string root_workspace_path = 2; -} -message EndResult { // aiserver.v1.EndResult -} -message EditResult { // aiserver.v1.EditResult - message RelatedInformation { // aiserver.v1.EditResult.RelatedInformation - string message = 1; - int32 start_line_number = 2; - int32 end_line_number = 3; - string relative_workspace_path = 4; - } - message Feedback { // aiserver.v1.EditResult.Feedback - string message = 1; - string severity = 2; - int32 start_line_number = 3; - int32 end_line_number = 4; - repeated RelatedInformation related_information = 5; - } - repeated string feedback = 1; - int32 context_start_line_number = 2; - repeated string context_lines = 3; - string file = 4; - int32 file_total_lines = 5; - repeated Feedback structured_feedback = 6; -} -message DeleteTestResult { // aiserver.v1.DeleteTestResult -} -message DeleteFileResult { // aiserver.v1.DeleteFileResult - bool rejected = 1; - bool file_non_existent = 2; - bool file_deleted_successfully = 3; -} -message CreateRmFilesResult { // aiserver.v1.CreateRmFilesResult - repeated string created_file_paths = 1; - repeated string removed_file_paths = 2; -} -message CreateFileResult { // aiserver.v1.CreateFileResult - bool file_created_successfully = 1; - bool file_already_exists = 2; -} -message AddUiStepResult { // aiserver.v1.AddUiStepResult -} -message AddTestResult { // aiserver.v1.AddTestResult - message RelatedInformation { // aiserver.v1.AddTestResult.RelatedInformation - string message = 1; - int32 start_line_number = 2; - int32 end_line_number = 3; - string relative_workspace_path = 4; - } - message Feedback { // aiserver.v1.AddTestResult.Feedback - string message = 1; - string severity = 2; - int32 start_line_number = 3; - int32 end_line_number = 4; - repeated RelatedInformation related_information = 5; - } - repeated Feedback feedback = 1; -} -message SuggestedCodeBlock { // aiserver.v1.SuggestedCodeBlock - string relative_workspace_path = 1; -} -message SimpleFileDiff { // aiserver.v1.SimpleFileDiff - message Chunk { // aiserver.v1.SimpleFileDiff.Chunk - repeated string old_lines = 1; - repeated string new_lines = 2; - LineRange old_range = 3; - LineRange new_range = 4; - } - string relative_workspace_path = 1; - repeated Chunk chunks = 3; -} -message LineRange { // aiserver.v1.LineRange - int32 start_line_number = 1; - int32 end_line_number_inclusive = 2; -} -message RedDiff { // aiserver.v1.RedDiff - string relative_workspace_path = 1; - repeated SimplestRange red_ranges = 2; - repeated SimplestRange red_ranges_reversed = 3; - string start_hash = 4; - string end_hash = 5; -} -message PullRequest { // aiserver.v1.PullRequest - string title = 1; - string body = 2; - repeated FileDiff diff = 3; -} -message ListDirResult { // aiserver.v1.ListDirResult - message File { // aiserver.v1.ListDirResult.File - string name = 1; - bool is_directory = 2; - optional int64 size = 3; - optional google.protobuf.Timestamp last_modified = 4; - optional int32 num_children = 5; - optional int32 num_lines = 6; - } - repeated File files = 1; - string directory_relative_workspace_path = 2; -} -message LinterErrorsWithoutFileContents { // aiserver.v1.LinterErrorsWithoutFileContents - string relative_workspace_path = 1; - repeated LinterError errors = 2; -} -message InterpreterResult { // aiserver.v1.InterpreterResult - string output = 1; - bool success = 2; -} -message ImageProto { // aiserver.v1.ImageProto - message Dimension { // aiserver.v1.ImageProto.Dimension - int32 width = 1; - int32 height = 2; - } - bytes data = 1; - Dimension dimension = 2; -} -message GitDiff { // aiserver.v1.GitDiff - enum DiffType { // aiserver.v1.GitDiff.DiffType - DIFF_TYPE_UNSPECIFIED = 0; - DIFF_TYPE_DIFF_TO_HEAD = 1; - DIFF_TYPE_DIFF_FROM_BRANCH_TO_MAIN = 2; - } - repeated FileDiff diffs = 1; - DiffType diff_type = 2; -} -message GetLintsForChangeResponse { // aiserver.v1.GetLintsForChangeResponse - message Lint { // aiserver.v1.GetLintsForChangeResponse.Lint - message QuickFix { // aiserver.v1.GetLintsForChangeResponse.Lint.QuickFix - message Edit { // aiserver.v1.GetLintsForChangeResponse.Lint.QuickFix.Edit - string relative_workspace_path = 1; - string text = 2; - int32 start_line_number_one_indexed = 3; - int32 start_column_one_indexed = 4; - int32 end_line_number_inclusive_one_indexed = 5; - int32 end_column_one_indexed = 6; - } - string message = 1; - string kind = 2; - bool is_preferred = 3; - repeated Edit edits = 4; - } - string message = 1; - string severity = 2; - string relative_workspace_path = 3; - int32 start_line_number_one_indexed = 4; - int32 start_column_one_indexed = 5; - int32 end_line_number_inclusive_one_indexed = 6; - int32 end_column_one_indexed = 7; - repeated QuickFix quick_fixes = 9; - } - repeated Lint lints = 1; -} -message Lint { // aiserver.v1.Lint - string message = 1; - SimpleRange range = 2; - LintSeverity severity = 3; -} -enum LintSeverity { // aiserver.v1.LintSeverity - LINT_SEVERITY_UNSPECIFIED = 0; - LINT_SEVERITY_ERROR = 1; - LINT_SEVERITY_WARNING = 2; - LINT_SEVERITY_INFO = 3; - LINT_SEVERITY_HINT = 4; - LINT_SEVERITY_AI = 5; -} -message Edit { // aiserver.v1.Edit - string text = 1; - IRange range = 2; -} -message IRange { // aiserver.v1.IRange - int32 start_line_number = 1; - int32 start_column = 2; - int32 end_line_number = 3; - int32 end_column = 4; + int32 line_number = 2; + string text = 3; } message FolderInfo { // aiserver.v1.FolderInfo string relative_path = 1; @@ -894,18 +1141,46 @@ message FolderFileInfo { // aiserver.v1.FolderFileInfo bool truncated = 3; float score = 4; } -message DocsReference { // aiserver.v1.DocsReference - string title = 1; - string url = 2; - string chunk = 3; - string name = 4; +message InterpreterResult { // aiserver.v1.InterpreterResult + string output = 1; + bool success = 2; } -message DiffHistoryData { // aiserver.v1.DiffHistoryData +message SimpleFileDiff { // aiserver.v1.SimpleFileDiff + message Chunk { // aiserver.v1.SimpleFileDiff.Chunk + repeated string old_lines = 1; + repeated string new_lines = 2; + LineRange old_range = 3; + LineRange new_range = 4; + } string relative_workspace_path = 1; - repeated ComposerFileDiff diffs = 2; - double timestamp = 3; - string unique_id = 4; - ComposerFileDiff start_to_end_diff = 5; + repeated Chunk chunks = 3; +} +message Commit { // aiserver.v1.Commit + string sha = 1; + string message = 2; + string description = 3; + repeated FileDiff diff = 4; + string author = 5; + string date = 6; +} +message PullRequest { // aiserver.v1.PullRequest + string title = 1; + string body = 2; + repeated FileDiff diff = 3; +} +message SuggestedCodeBlock { // aiserver.v1.SuggestedCodeBlock + string relative_workspace_path = 1; +} +message UserResponseToSuggestedCodeBlock { // aiserver.v1.UserResponseToSuggestedCodeBlock + enum UserResponseType { // aiserver.v1.UserResponseToSuggestedCodeBlock.UserResponseType + USER_RESPONSE_TYPE_UNSPECIFIED = 0; + USER_RESPONSE_TYPE_ACCEPT = 1; + USER_RESPONSE_TYPE_REJECT = 2; + USER_RESPONSE_TYPE_MODIFY = 3; + } + UserResponseType user_response_type = 1; + string file_path = 2; + optional FileDiff user_modifications_to_suggested_code_blocks = 3; } message ComposerFileDiff { // aiserver.v1.ComposerFileDiff enum Editor { // aiserver.v1.ComposerFileDiff.Editor @@ -926,462 +1201,12 @@ message ComposerFileDiff { // aiserver.v1.ComposerFileDiff Editor editor = 2; bool hit_timeout = 3; } -message ConversationSummary { // aiserver.v1.ConversationSummary - string summary = 1; - string truncation_last_bubble_id_inclusive = 2; - string client_should_start_sending_from_inclusive_bubble_id = 3; - string previous_conversation_summary_bubble_id = 4; - bool includes_tool_results = 5; -} -message ComposerFileDiffHistory { // aiserver.v1.ComposerFileDiffHistory - string file_name = 1; - repeated string diff_history = 2; - repeated double diff_history_timestamps = 3; -} -message ComposerCapabilityRequest { // aiserver.v1.ComposerCapabilityRequest - enum ComposerCapabilityType { // aiserver.v1.ComposerCapabilityRequest.ComposerCapabilityType - COMPOSER_CAPABILITY_TYPE_UNSPECIFIED = 0; - COMPOSER_CAPABILITY_TYPE_LOOP_ON_LINTS = 1; - COMPOSER_CAPABILITY_TYPE_LOOP_ON_TESTS = 2; - COMPOSER_CAPABILITY_TYPE_MEGA_PLANNER = 3; - COMPOSER_CAPABILITY_TYPE_LOOP_ON_COMMAND = 4; - COMPOSER_CAPABILITY_TYPE_TOOL_CALL = 5; - COMPOSER_CAPABILITY_TYPE_DIFF_REVIEW = 6; - COMPOSER_CAPABILITY_TYPE_CONTEXT_PICKING = 7; - COMPOSER_CAPABILITY_TYPE_EDIT_TRAIL = 8; - COMPOSER_CAPABILITY_TYPE_AUTO_CONTEXT = 9; - COMPOSER_CAPABILITY_TYPE_CONTEXT_PLANNER = 10; - COMPOSER_CAPABILITY_TYPE_DIFF_HISTORY = 11; - COMPOSER_CAPABILITY_TYPE_REMEMBER_THIS = 12; - COMPOSER_CAPABILITY_TYPE_DECOMPOSER = 13; - COMPOSER_CAPABILITY_TYPE_USES_CODEBASE = 14; - COMPOSER_CAPABILITY_TYPE_TOOL_FORMER = 15; - COMPOSER_CAPABILITY_TYPE_CURSOR_RULES = 16; - } - enum ToolType { // aiserver.v1.ComposerCapabilityRequest.ToolType - TOOL_TYPE_UNSPECIFIED = 0; - TOOL_TYPE_ADD_FILE_TO_CONTEXT = 1; - TOOL_TYPE_RUN_TERMINAL_COMMAND = 2; - TOOL_TYPE_ITERATE = 3; - TOOL_TYPE_REMOVE_FILE_FROM_CONTEXT = 4; - TOOL_TYPE_SEMANTIC_SEARCH_CODEBASE = 5; - } - message ToolSchema { // aiserver.v1.ComposerCapabilityRequest.ToolSchema - ToolType type = 1; - string name = 2; - map properties = 3; - repeated string required = 4; - } - message SchemaProperty { // aiserver.v1.ComposerCapabilityRequest.SchemaProperty - string type = 1; - optional string description = 2; - } - message LoopOnLintsCapability { // aiserver.v1.ComposerCapabilityRequest.LoopOnLintsCapability - repeated LinterErrors linter_errors = 1; - optional string custom_instructions = 2; - } - message LoopOnTestsCapability { // aiserver.v1.ComposerCapabilityRequest.LoopOnTestsCapability - repeated string test_names = 1; - optional string custom_instructions = 2; - } - message MegaPlannerCapability { // aiserver.v1.ComposerCapabilityRequest.MegaPlannerCapability - optional string custom_instructions = 1; - } - message LoopOnCommandCapability { // aiserver.v1.ComposerCapabilityRequest.LoopOnCommandCapability - string command = 1; - optional string custom_instructions = 2; - optional string output = 3; - optional int32 exit_code = 4; - } - message ToolCallCapability { // aiserver.v1.ComposerCapabilityRequest.ToolCallCapability - optional string custom_instructions = 1; - repeated ToolSchema tool_schemas = 2; - repeated string relevant_files = 3; - repeated string files_in_context = 4; - repeated string semantic_search_files = 5; - } - message DiffReviewCapability { // aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability - message SimpleFileDiff { // aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability.SimpleFileDiff - message Chunk { // aiserver.v1.ComposerCapabilityRequest.DiffReviewCapability.SimpleFileDiff.Chunk - repeated string old_lines = 1; - repeated string new_lines = 2; - LineRange old_range = 3; - LineRange new_range = 4; - } - string relative_workspace_path = 1; - repeated Chunk chunks = 3; - } - optional string custom_instructions = 1; - repeated SimpleFileDiff diffs = 2; - } - message DecomposerCapability { // aiserver.v1.ComposerCapabilityRequest.DecomposerCapability - optional string custom_instructions = 1; - } - message ContextPickingCapability { // aiserver.v1.ComposerCapabilityRequest.ContextPickingCapability - optional string custom_instructions = 1; - repeated string potential_context_files = 2; - repeated CodeChunk potential_context_code_chunks = 3; - repeated string files_in_context = 4; - } - message EditTrailCapability { // aiserver.v1.ComposerCapabilityRequest.EditTrailCapability - optional string custom_instructions = 1; - } - message AutoContextCapability { // aiserver.v1.ComposerCapabilityRequest.AutoContextCapability - optional string custom_instructions = 1; - repeated string additional_files = 2; - } - message ContextPlannerCapability { // aiserver.v1.ComposerCapabilityRequest.ContextPlannerCapability - optional string custom_instructions = 1; - repeated CodeChunk attached_code_chunks = 2; - } - message RememberThisCapability { // aiserver.v1.ComposerCapabilityRequest.RememberThisCapability - optional string custom_instructions = 1; - string memory = 2; - } - message CursorRulesCapability { // aiserver.v1.ComposerCapabilityRequest.CursorRulesCapability - optional string custom_instructions = 1; - } - ComposerCapabilityType type = 1; - oneof data { - LoopOnLintsCapability loop_on_lints = 2; - LoopOnTestsCapability loop_on_tests = 3; - MegaPlannerCapability mega_planner = 4; - LoopOnCommandCapability loop_on_command = 5; - ToolCallCapability tool_call = 6; - DiffReviewCapability diff_review = 7; - ContextPickingCapability context_picking = 8; - EditTrailCapability edit_trail = 9; - AutoContextCapability auto_context = 10; - ContextPlannerCapability context_planner = 11; - RememberThisCapability remember_this = 12; - DecomposerCapability decomposer = 13; - CursorRulesCapability cursor_rules = 14; - } -} -message CodeChunk { // aiserver.v1.CodeChunk - enum Intent { // aiserver.v1.CodeChunk.Intent - INTENT_UNSPECIFIED = 0; - INTENT_COMPOSER_FILE = 1; - INTENT_COMPRESSED_COMPOSER_FILE = 2; - } - enum SummarizationStrategy { // aiserver.v1.CodeChunk.SummarizationStrategy - SUMMARIZATION_STRATEGY_NONE_UNSPECIFIED = 0; - SUMMARIZATION_STRATEGY_SUMMARIZED = 1; - SUMMARIZATION_STRATEGY_EMBEDDED = 2; - } +message DiffHistoryData { // aiserver.v1.DiffHistoryData string relative_workspace_path = 1; - int32 start_line_number = 2; - repeated string lines = 3; - optional SummarizationStrategy summarization_strategy = 4; - string language_identifier = 5; - optional Intent intent = 6; - optional bool is_final_version = 7; - optional bool is_first_version = 8; -} -message Commit { // aiserver.v1.Commit - string sha = 1; - string message = 2; - string description = 3; - repeated FileDiff diff = 4; - string author = 5; - string date = 6; -} -message ClientSideToolV2Result { // aiserver.v1.ClientSideToolV2Result - ClientSideToolV2 tool = 1; - oneof result { - ReadSemsearchFilesResult read_semsearch_files_result = 2; - ReadFileForImportsResult read_file_for_imports_result = 3; - RipgrepSearchResult ripgrep_search_result = 4; - RunTerminalCommandResult run_terminal_command_result = 5; - ReadFileResult read_file_result = 6; - ListDirResult list_dir_result = 9; - EditFileResult edit_file_result = 10; - ToolCallFileSearchResult file_search_result = 11; - SemanticSearchFullResult semantic_search_full_result = 18; - CreateFileResult create_file_result = 19; - DeleteFileResult delete_file_result = 20; - ReapplyResult reapply_result = 21; - GetRelatedFilesResult get_related_files_result = 22; - ParallelApplyResult parallel_apply_result = 23; - RunTerminalCommandV2Result run_terminal_command_v2_result = 24; - FetchRulesResult fetch_rules_result = 25; - PlannerResult planner_result = 26; - WebSearchResult web_search_result = 27; - MCPResult mcp_result = 28; - WebViewerResult web_viewer_result = 29; - DiffHistoryResult diff_history_result = 30; - } - optional ToolResultError error = 8; -} -enum ClientSideToolV2 { // aiserver.v1.ClientSideToolV2 - CLIENT_SIDE_TOOL_V2_UNSPECIFIED = 0; - CLIENT_SIDE_TOOL_V2_READ_SEMSEARCH_FILES = 1; - CLIENT_SIDE_TOOL_V2_READ_FILE_FOR_IMPORTS = 2; - CLIENT_SIDE_TOOL_V2_RIPGREP_SEARCH = 3; - CLIENT_SIDE_TOOL_V2_RUN_TERMINAL_COMMAND = 4; - CLIENT_SIDE_TOOL_V2_READ_FILE = 5; - CLIENT_SIDE_TOOL_V2_LIST_DIR = 6; - CLIENT_SIDE_TOOL_V2_EDIT_FILE = 7; - CLIENT_SIDE_TOOL_V2_FILE_SEARCH = 8; - CLIENT_SIDE_TOOL_V2_SEMANTIC_SEARCH_FULL = 9; - CLIENT_SIDE_TOOL_V2_CREATE_FILE = 10; - CLIENT_SIDE_TOOL_V2_DELETE_FILE = 11; - CLIENT_SIDE_TOOL_V2_REAPPLY = 12; - CLIENT_SIDE_TOOL_V2_GET_RELATED_FILES = 13; - CLIENT_SIDE_TOOL_V2_PARALLEL_APPLY = 14; - CLIENT_SIDE_TOOL_V2_RUN_TERMINAL_COMMAND_V2 = 15; - CLIENT_SIDE_TOOL_V2_FETCH_RULES = 16; - CLIENT_SIDE_TOOL_V2_PLANNER = 17; - CLIENT_SIDE_TOOL_V2_WEB_SEARCH = 18; - CLIENT_SIDE_TOOL_V2_MCP = 19; - CLIENT_SIDE_TOOL_V2_WEB_VIEWER = 20; - CLIENT_SIDE_TOOL_V2_DIFF_HISTORY = 21; -} -message WebViewerResult { // aiserver.v1.WebViewerResult - string url = 1; - ImageProto screenshot = 2; -} -message WebSearchResult { // aiserver.v1.WebSearchResult - message WebReference { // aiserver.v1.WebSearchResult.WebReference - string title = 1; - string url = 2; - string chunk = 3; - } - repeated WebReference references = 1; -} -message ToolCallFileSearchResult { // aiserver.v1.ToolCallFileSearchResult - message File { // aiserver.v1.ToolCallFileSearchResult.File - string uri = 1; - } - repeated File files = 1; - optional bool limit_hit = 2; - int32 num_results = 3; -} -message SemanticSearchFullResult { // aiserver.v1.SemanticSearchFullResult - repeated CodeResult code_results = 1; - repeated File all_files = 2; - repeated MissingFile missing_files = 3; -} -message RunTerminalCommandV2Result { // aiserver.v1.RunTerminalCommandV2Result - string output = 1; - int32 exit_code = 2; - optional bool rejected = 3; - bool popped_out_into_background = 4; - bool is_running_in_background = 5; - bool not_interrupted = 6; - string resulting_working_directory = 7; - bool did_user_change = 8; - RunTerminalCommandEndedReason ended_reason = 9; - optional int32 exit_code_v2 = 10; -} -enum RunTerminalCommandEndedReason { // aiserver.v1.RunTerminalCommandEndedReason - RUN_TERMINAL_COMMAND_ENDED_REASON_UNSPECIFIED = 0; - RUN_TERMINAL_COMMAND_ENDED_REASON_EXECUTION_COMPLETED = 1; - RUN_TERMINAL_COMMAND_ENDED_REASON_EXECUTION_ABORTED = 2; - RUN_TERMINAL_COMMAND_ENDED_REASON_EXECUTION_FAILED = 3; - RUN_TERMINAL_COMMAND_ENDED_REASON_ERROR_OCCURRED_CHECKING_REASON = 4; -} -message RunTerminalCommandResult { // aiserver.v1.RunTerminalCommandResult - string output = 1; - int32 exit_code = 2; - optional bool rejected = 3; - bool popped_out_into_background = 4; -} -message RipgrepSearchResult { // aiserver.v1.RipgrepSearchResult - RipgrepSearchResultInternal internal = 1; -} -message RipgrepSearchResultInternal { // aiserver.v1.RipgrepSearchResultInternal - enum TextSearchCompleteMessageType { // aiserver.v1.RipgrepSearchResultInternal.TextSearchCompleteMessageType - TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_UNSPECIFIED = 0; - TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_INFORMATION = 1; - TEXT_SEARCH_COMPLETE_MESSAGE_TYPE_WARNING = 2; - } - enum SearchCompletionExitCode { // aiserver.v1.RipgrepSearchResultInternal.SearchCompletionExitCode - SEARCH_COMPLETION_EXIT_CODE_UNSPECIFIED = 0; - SEARCH_COMPLETION_EXIT_CODE_NORMAL = 1; - SEARCH_COMPLETION_EXIT_CODE_NEW_SEARCH_STARTED = 2; - } - message IFileMatch { // aiserver.v1.RipgrepSearchResultInternal.IFileMatch - string resource = 1; - repeated ITextSearchResult results = 2; - } - message ITextSearchResult { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchResult - oneof result { - ITextSearchMatch match = 1; - ITextSearchContext context = 2; - } - } - message ITextSearchMatch { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchMatch - optional string uri = 1; - repeated ISearchRangeSetPairing range_locations = 2; - string preview_text = 3; - optional int32 webview_index = 4; - optional string cell_fragment = 5; - } - message ITextSearchContext { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchContext - optional string uri = 1; - string text = 2; - int32 line_number = 3; - } - message ISearchRangeSetPairing { // aiserver.v1.RipgrepSearchResultInternal.ISearchRangeSetPairing - ISearchRange source = 1; - ISearchRange preview = 2; - } - message ISearchRange { // aiserver.v1.RipgrepSearchResultInternal.ISearchRange - int32 start_line_number = 1; - int32 start_column = 2; - int32 end_line_number = 3; - int32 end_column = 4; - } - message ITextSearchCompleteMessage { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchCompleteMessage - string text = 1; - TextSearchCompleteMessageType type = 2; - optional bool trusted = 3; - } - message IFileSearchStats { // aiserver.v1.RipgrepSearchResultInternal.IFileSearchStats - enum FileSearchProviderType { // aiserver.v1.RipgrepSearchResultInternal.IFileSearchStats.FileSearchProviderType - FILE_SEARCH_PROVIDER_TYPE_UNSPECIFIED = 0; - FILE_SEARCH_PROVIDER_TYPE_FILE_SEARCH_PROVIDER = 1; - FILE_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS = 2; - } - bool from_cache = 1; - oneof detail_stats { - ISearchEngineStats search_engine_stats = 2; - ICachedSearchStats cached_search_stats = 3; - IFileSearchProviderStats file_search_provider_stats = 4; - } - int32 result_count = 5; - FileSearchProviderType type = 6; - optional int32 sorting_time = 7; - } - message ITextSearchStats { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchStats - enum TextSearchProviderType { // aiserver.v1.RipgrepSearchResultInternal.ITextSearchStats.TextSearchProviderType - TEXT_SEARCH_PROVIDER_TYPE_UNSPECIFIED = 0; - TEXT_SEARCH_PROVIDER_TYPE_TEXT_SEARCH_PROVIDER = 1; - TEXT_SEARCH_PROVIDER_TYPE_SEARCH_PROCESS = 2; - TEXT_SEARCH_PROVIDER_TYPE_AI_TEXT_SEARCH_PROVIDER = 3; - } - TextSearchProviderType type = 1; - } - message ISearchEngineStats { // aiserver.v1.RipgrepSearchResultInternal.ISearchEngineStats - int32 file_walk_time = 1; - int32 directories_walked = 2; - int32 files_walked = 3; - int32 cmd_time = 4; - optional int32 cmd_result_count = 5; - } - message ICachedSearchStats { // aiserver.v1.RipgrepSearchResultInternal.ICachedSearchStats - bool cache_was_resolved = 1; - int32 cache_lookup_time = 2; - int32 cache_filter_time = 3; - int32 cache_entry_count = 4; - } - message IFileSearchProviderStats { // aiserver.v1.RipgrepSearchResultInternal.IFileSearchProviderStats - int32 provider_time = 1; - int32 post_process_time = 2; - } - repeated IFileMatch results = 1; - optional SearchCompletionExitCode exit = 2; - optional bool limit_hit = 3; - repeated ITextSearchCompleteMessage messages = 4; - oneof stats { - IFileSearchStats file_search_stats = 5; - ITextSearchStats text_search_stats = 6; - } -} -message ReapplyResult { // aiserver.v1.ReapplyResult - EditFileResult.FileDiff diff = 1; - bool is_applied = 2; - bool apply_failed = 3; - repeated LinterError linter_errors = 4; -} -message ReadFileResult { // aiserver.v1.ReadFileResult - string contents = 1; - bool did_downgrade_to_line_range = 2; - bool did_shorten_line_range = 3; - bool did_set_default_line_range = 4; - optional string full_file_contents = 5; - optional string outline = 6; - optional int32 start_line_one_indexed = 7; - optional int32 end_line_one_indexed_inclusive = 8; - string relative_workspace_path = 9; - bool did_shorten_char_range = 10; -} -message ReadFileForImportsResult { // aiserver.v1.ReadFileForImportsResult - string contents = 1; -} -message PlannerResult { // aiserver.v1.PlannerResult - string plan = 1; -} -message ParallelApplyResult { // aiserver.v1.ParallelApplyResult - message FileResult { // aiserver.v1.ParallelApplyResult.FileResult - string file_path = 1; - EditFileResult.FileDiff diff = 2; - bool is_applied = 3; - bool apply_failed = 4; - optional string error = 5; - repeated LinterError linter_errors = 6; - } - repeated FileResult file_results = 1; - optional string error = 2; -} -message FileResult { // aiserver.v1.FileResult - File file = 1; - float score = 2; -} -message MCPResult { // aiserver.v1.MCPResult - string selected_tool = 1; - string result = 2; -} -message GetRelatedFilesResult { // aiserver.v1.GetRelatedFilesResult - message File { // aiserver.v1.GetRelatedFilesResult.File - string uri = 1; - float score = 2; - } - repeated File files = 1; -} -message FetchRulesResult { // aiserver.v1.FetchRulesResult - repeated CursorRule rules = 1; -} -message EditFileResult { // aiserver.v1.EditFileResult - message FileDiff { // aiserver.v1.EditFileResult.FileDiff - enum Editor { // aiserver.v1.EditFileResult.FileDiff.Editor - EDITOR_UNSPECIFIED = 0; - EDITOR_AI = 1; - EDITOR_HUMAN = 2; - } - message ChunkDiff { // aiserver.v1.EditFileResult.FileDiff.ChunkDiff - string diff_string = 1; - int32 old_start = 2; - int32 new_start = 3; - int32 old_lines = 4; - int32 new_lines = 5; - int32 lines_removed = 6; - int32 lines_added = 7; - } - repeated ChunkDiff chunks = 1; - Editor editor = 2; - bool hit_timeout = 3; - } - FileDiff diff = 1; - bool is_applied = 2; - bool apply_failed = 3; - repeated LinterError linter_errors = 4; -} -message DiffHistoryResult { // aiserver.v1.DiffHistoryResult - message RenderedDiff { // aiserver.v1.DiffHistoryResult.RenderedDiff - int32 start_line_number = 1; - int32 end_line_number_exclusive = 2; - repeated string before_context_lines = 3; - repeated string removed_lines = 4; - repeated string added_lines = 5; - repeated string after_context_lines = 6; - } - message HumanChange { // aiserver.v1.DiffHistoryResult.HumanChange - string relative_workspace_path = 1; - repeated RenderedDiff rendered_diffs = 2; - } - repeated HumanChange human_changes = 40; + repeated ComposerFileDiff diffs = 2; + double timestamp = 3; + string unique_id = 4; + ComposerFileDiff start_to_end_diff = 5; } message ContextAST { // aiserver.v1.ContextAST repeated ContainerTree files = 1; @@ -1418,20 +1243,105 @@ message ContainerTreeNode { // aiserver.v1.ContainerTreeNode Symbol symbol = 3; } } -message CommitNote { // aiserver.v1.CommitNote - string note = 1; - string commit_hash = 2; +message AvailableModelsRequest { // aiserver.v1.AvailableModelsRequest + bool is_nightly = 1; + bool include_long_context_models = 2; } -message ChatQuote { // aiserver.v1.ChatQuote - string markdown = 1; - string bubble_id = 2; - int32 section_index = 3; +message AvailableModelsResponse { // aiserver.v1.AvailableModelsResponse + enum DegradationStatus { // aiserver.v1.AvailableModelsResponse.DegradationStatus + DEGRADATION_STATUS_UNSPECIFIED = 0; + DEGRADATION_STATUS_DEGRADED = 1; + DEGRADATION_STATUS_DISABLED = 2; + } + message TooltipData { // aiserver.v1.AvailableModelsResponse.TooltipData + string primary_text = 1; + string secondary_text = 2; + bool secondary_warning_text = 3; + string icon = 4; + } + message AvailableModel { // aiserver.v1.AvailableModelsResponse.AvailableModel + string name = 1; + bool default_on = 2; + optional bool is_long_context_only = 3; + optional bool is_chat_only = 4; + optional bool supports_agent = 5; + optional DegradationStatus degradation_status = 6; + optional double price = 7; + optional TooltipData tooltip_data = 8; + } + repeated AvailableModel models = 2; + repeated string model_names = 1; } -message ChatExternalLink { // aiserver.v1.ChatExternalLink - string url = 1; - string uuid = 2; +message DebugInfo { // aiserver.v1.DebugInfo + message Variable { // aiserver.v1.DebugInfo.Variable + string name = 1; + string value = 2; + optional string type = 3; + } + message Scope { // aiserver.v1.DebugInfo.Scope + string name = 1; + repeated Variable variables = 2; + } + message CallStackFrame { // aiserver.v1.DebugInfo.CallStackFrame + string relative_workspace_path = 1; + int32 line_number = 2; + string function_name = 3; + repeated Scope scopes = 4; + } + message Breakpoint { // aiserver.v1.DebugInfo.Breakpoint + string relative_workspace_path = 1; + int32 line_number = 2; + repeated string lines_before_breakpoint = 3; + repeated string lines_after_breakpoint = 4; + optional string exception_info = 5; + } + Breakpoint breakpoint = 1; + repeated CallStackFrame call_stack = 2; + repeated CodeBlock history = 3; +} +message GetChatRequest { // aiserver.v1.GetChatRequest + CurrentFileInfo current_file = 1; + repeated ConversationMessage conversation = 2; + repeated RepositoryInfo repositories = 3; + ExplicitContext explicit_context = 4; + optional string workspace_root_path = 5; + repeated CodeBlock code_blocks = 6; + ModelDetails model_details = 7; + repeated string documentation_identifiers = 8; + string request_id = 9; + LinterErrors linter_errors = 10; + optional string summary = 11; + optional int32 summary_up_until_index = 12; + optional bool allow_long_file_scan = 13; + optional bool is_bash = 14; + string conversation_id = 15; + optional bool can_handle_filenames_after_language_ids = 16; + optional string use_web = 17; + repeated ChatQuote quotes = 18; + optional DebugInfo debug_info = 19; + optional string workspace_id = 20; + repeated ChatExternalLink external_links = 21; + repeated CommitNote commit_notes = 23; + optional bool long_context_mode = 22; + optional bool is_eval = 24; + optional int32 desired_max_tokens = 26; + ContextAST context_ast = 25; + optional bool is_composer = 27; + optional bool runnable_code_blocks = 28; + optional bool should_cache = 29; + optional bool allow_model_fallbacks = 30; + optional int32 number_of_times_shown_fallback_model_warning = 31; +} +message ServerTimingInfo { // aiserver.v1.ServerTimingInfo + double server_start_time = 1; + double server_first_token_time = 2; + double server_request_sent_time = 3; + double server_end_time = 4; } message StreamChatResponse { // aiserver.v1.StreamChatResponse + message UsedCode { // aiserver.v1.StreamChatResponse.UsedCode + repeated CodeResult code_results = 1; + } message ChunkIdentity { // aiserver.v1.StreamChatResponse.ChunkIdentity string file_name = 1; int32 start_line = 2; @@ -1457,52 +1367,14 @@ message StreamChatResponse { // aiserver.v1.StreamChatResponse optional FileLink file_link = 15; optional ConversationSummary conversation_summary = 16; optional ServiceStatusUpdate service_status_update = 17; + optional UsedCode used_code = 18; + optional bool stop_using_dsv3_agentic_model = 26; + optional string usage_uuid = 27; } -message WebCitation { // aiserver.v1.WebCitation - repeated WebReference references = 1; +message GetTokenUsageRequest { // aiserver.v1.GetTokenUsageRequest + string usage_uuid = 1; } -message SymbolLink { // aiserver.v1.SymbolLink - string symbol_name = 1; - string symbol_search_string = 2; - string relative_workspace_path = 3; - int32 rough_line_number = 4; -} -message StatusUpdates { // aiserver.v1.StatusUpdates - repeated StatusUpdate updates = 1; -} -message StatusUpdate { // aiserver.v1.StatusUpdate - string message = 1; - optional string metadata = 2; -} -message ServiceStatusUpdate { // aiserver.v1.ServiceStatusUpdate - string message = 1; - string codicon = 2; - optional bool allow_command_links_potentially_unsafe_please_only_use_for_handwritten_trusted_markdown = 3; - optional string action_to_run_on_status_update = 4; -} -message ServerTimingInfo { // aiserver.v1.ServerTimingInfo - double server_start_time = 1; - double server_first_token_time = 2; - double server_request_sent_time = 3; - double server_end_time = 4; -} -message FileLink { // aiserver.v1.FileLink - string display_name = 1; - string relative_workspace_path = 2; -} -message DocumentationCitation { // aiserver.v1.DocumentationCitation - repeated DocumentationChunk chunks = 1; -} -message DocumentationChunk { // aiserver.v1.DocumentationChunk - string doc_name = 1; - string page_url = 2; - string documentation_chunk = 3; - float score = 4; - string page_title = 5; -} -enum ChunkType { // aiserver.v1.ChunkType - CHUNK_TYPE_UNSPECIFIED = 0; - CHUNK_TYPE_CODEBASE = 1; - CHUNK_TYPE_LONG_FILE = 2; - CHUNK_TYPE_DOCS = 3; +message GetTokenUsageResponse { // aiserver.v1.GetTokenUsageResponse + int32 input_tokens = 1; + int32 output_tokens = 2; } diff --git a/src/chat/aiserver/v1/timestamp.proto b/src/cursor/aiserver/v1/timestamp.proto similarity index 100% rename from src/chat/aiserver/v1/timestamp.proto rename to src/cursor/aiserver/v1/timestamp.proto diff --git a/src/chat/config.rs b/src/cursor/config.rs similarity index 100% rename from src/chat/config.rs rename to src/cursor/config.rs diff --git a/src/chat/config/key.proto b/src/cursor/config/key.proto similarity index 100% rename from src/chat/config/key.proto rename to src/cursor/config/key.proto diff --git a/src/chat/constant.rs b/src/cursor/constant.rs similarity index 91% rename from src/chat/constant.rs rename to src/cursor/constant.rs index c3ce30d..94b6f4d 100644 --- a/src/chat/constant.rs +++ b/src/cursor/constant.rs @@ -7,12 +7,6 @@ use std::{ use super::model::Model; macro_rules! def_pub_const { - // 单个常量定义分支 - // ($name:ident, $value:expr) => { - // pub const $name: &'static str = $value; - // }; - - // 批量定义分支 ($($name:ident => $value:expr),+ $(,)?) => { $( pub const $name: &'static str = $value; @@ -52,6 +46,8 @@ def_pub_const!( CLAUDE_3_5_HAIKU => "claude-3.5-haiku", CLAUDE_3_7_SONNET => "claude-3.7-sonnet", CLAUDE_3_7_SONNET_THINKING => "claude-3.7-sonnet-thinking", + CLAUDE_3_7_SONNET_MAX => "claude-3.7-sonnet-max", + CLAUDE_3_7_SONNET_THINKING_MAX => "claude-3.7-sonnet-thinking-max", // OpenAI 模型 GPT_4 => "gpt-4", @@ -95,7 +91,7 @@ macro_rules! create_models { models: Arc::new(vec![ $( Model { - id: $model.into(), + id: $model, created: CREATED, object: MODEL_OBJECT, owned_by: $owner, @@ -130,22 +126,22 @@ impl Models { // } // 检查模型是否存在 - pub fn exists(model_id: &str) -> bool { - Self::read().models.iter().any(|m| m.id == model_id) - } + // pub fn exists(model_id: &str) -> bool { + // Self::read().models.iter().any(|m| m.id == model_id) + // } // 查找模型并返回其 ID - pub fn find_id(model: &str) -> Option { + pub fn find_id(model: &str) -> Option<&'static str> { Self::read() .models .iter() .find(|m| m.id == model) - .map(|m| m.id.clone()) + .map(|m| m.id) } // 返回所有模型 ID 的列表 - pub fn ids() -> Vec { - Self::read().models.iter().map(|m| m.id.clone()).collect() + pub fn ids() -> Vec<&'static str> { + Self::read().models.iter().map(|m| m.id).collect() } // 写入方法 @@ -180,9 +176,12 @@ impl Models { // } create_models!( + DEFAULT => UNKNOWN, CLAUDE_3_5_SONNET => ANTHROPIC, CLAUDE_3_7_SONNET => ANTHROPIC, CLAUDE_3_7_SONNET_THINKING => ANTHROPIC, + CLAUDE_3_7_SONNET_MAX => ANTHROPIC, + CLAUDE_3_7_SONNET_THINKING_MAX => ANTHROPIC, GPT_4 => OPENAI, GPT_4O => OPENAI, GPT_4_5_PREVIEW => OPENAI, @@ -207,7 +206,6 @@ create_models!( DEEPSEEK_R1 => DEEPSEEK, O3_MINI => OPENAI, GROK_2 => XAI, - DEFAULT => UNKNOWN, ); pub const USAGE_CHECK_MODELS: [&str; 13] = [ diff --git a/src/chat/error.rs b/src/cursor/error.rs similarity index 83% rename from src/chat/error.rs rename to src/cursor/error.rs index d30dfc5..0b2b58b 100644 --- a/src/chat/error.rs +++ b/src/cursor/error.rs @@ -1,4 +1,4 @@ -use super::aiserver::v1::ErrorDetails; +use super::{aiserver::v1::ErrorDetails, constant::UNKNOWN}; use crate::common::model::{ApiStatus, ErrorResponse as CommonErrorResponse}; use base64::{Engine as _, engine::general_purpose::STANDARD_NO_PAD}; use prost::Message as _; @@ -46,7 +46,7 @@ impl ChatError { if self.error.details.is_empty() { return ErrorResponse { status: 500, - code: "unknown".to_string(), + code: UNKNOWN.to_string(), error: None, }; } @@ -98,7 +98,7 @@ impl ErrorResponse { // } pub fn status_code(&self) -> StatusCode { - StatusCode::from_u16(self.status).unwrap() + StatusCode::from_u16(self.status).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR) } pub fn native_code(&self) -> String { @@ -108,16 +108,25 @@ impl ErrorResponse { ) } - pub fn into_common(self) -> CommonErrorResponse { + pub fn details(&self) -> Option { + self.error.as_ref().map( + |error| error.details.clone(), + ) + } + + pub fn into_common(mut self) -> CommonErrorResponse { CommonErrorResponse { status: ApiStatus::Error, code: Some(self.status), error: self .error - .as_ref() - .map(|error| error.message.clone()) - .or(Some(self.code.clone())), - message: self.error.as_ref().map(|error| error.details.clone()), + .as_mut() + .map(|error| std::mem::take(&mut error.message)) + .or(Some(self.code)), + message: self + .error + .as_mut() + .map(|error| std::mem::take(&mut error.details)), } } } diff --git a/src/chat/middleware.rs b/src/cursor/middleware.rs similarity index 100% rename from src/chat/middleware.rs rename to src/cursor/middleware.rs diff --git a/src/chat/middleware/auth.rs b/src/cursor/middleware/auth.rs similarity index 100% rename from src/chat/middleware/auth.rs rename to src/cursor/middleware/auth.rs diff --git a/src/chat/model.rs b/src/cursor/model.rs similarity index 79% rename from src/chat/model.rs rename to src/cursor/model.rs index dc1db67..3e9039d 100644 --- a/src/chat/model.rs +++ b/src/cursor/model.rs @@ -12,7 +12,7 @@ pub enum MessageContent { #[derive(Serialize, Deserialize)] pub struct VisionMessageContent { #[serde(rename = "type")] - pub content_type: String, + pub rtype: String, #[serde(skip_serializing_if = "Option::is_none")] pub text: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -32,10 +32,11 @@ pub struct Message { pub content: MessageContent, } -#[derive(Serialize, Deserialize, PartialEq)] +#[derive(Serialize, Deserialize, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Clone, Copy, PartialEq)] +#[repr(u8)] pub enum Role { #[serde(rename = "system", alias = "developer")] - System, + System = 0u8, #[serde(rename = "user", alias = "human")] User, #[serde(rename = "assistant", alias = "ai")] @@ -48,7 +49,7 @@ pub struct ChatResponse { pub object: &'static str, pub created: i64, #[serde(skip_serializing_if = "Option::is_none")] - pub model: Option, + pub model: Option<&'static str>, pub choices: Vec, #[serde(skip_serializing_if = "TriState::is_none")] pub usage: TriState, @@ -75,9 +76,15 @@ pub struct Delta { #[derive(Serialize)] pub struct Usage { - pub prompt_tokens: u32, - pub completion_tokens: u32, - pub total_tokens: u32, + pub prompt_tokens: i32, + pub completion_tokens: i32, + pub total_tokens: i32, +} + +impl Default for Usage { + fn default() -> Self { + Self { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 } + } } // 聊天请求 @@ -97,9 +104,9 @@ pub struct StreamOptions { } // 模型定义 -#[derive(Serialize, Clone)] +#[derive(Serialize)] pub struct Model { - pub id: String, + pub id: &'static str, pub created: &'static i64, pub object: &'static str, pub owned_by: &'static str, @@ -112,15 +119,18 @@ impl PartialEq for Model { } use super::constant::{Models, USAGE_CHECK_MODELS}; -use crate::{app::model::{AppConfig, UsageCheck}, common::model::tri::TriState}; +use crate::{ + app::model::{AppConfig, UsageCheck}, + common::model::tri::TriState, +}; impl Model { - pub fn is_usage_check(model_id: &String, usage_check: Option) -> bool { + pub fn is_usage_check(model_id: &str, usage_check: Option) -> bool { match usage_check.unwrap_or(AppConfig::get_usage_check()) { UsageCheck::None => false, - UsageCheck::Default => USAGE_CHECK_MODELS.contains(&model_id.as_str()), + UsageCheck::Default => USAGE_CHECK_MODELS.contains(&model_id), UsageCheck::All => true, - UsageCheck::Custom(models) => models.contains(model_id), + UsageCheck::Custom(models) => models.contains(&model_id), } } } @@ -132,6 +142,7 @@ pub struct ModelsResponse { } impl ModelsResponse { + #[inline] pub(super) fn new(data: Arc>) -> Self { Self { object: "list", @@ -139,6 +150,7 @@ impl ModelsResponse { } } + #[inline] pub(super) fn with_default_models() -> Self { Self::new(Models::to_arc()) } diff --git a/src/chat/route.rs b/src/cursor/route.rs similarity index 78% rename from src/chat/route.rs rename to src/cursor/route.rs index 0430976..ce581a7 100644 --- a/src/chat/route.rs +++ b/src/cursor/route.rs @@ -6,8 +6,9 @@ mod token; pub use token::{handle_basic_calibration, handle_build_key}; mod tokens; pub use tokens::{ - handle_add_tokens, handle_delete_tokens, handle_get_tokens, handle_update_token_tags, - handle_update_tokens, handle_update_tokens_profile, + handle_add_tokens, handle_delete_tokens, handle_get_token_tags, handle_get_tokens, + handle_get_tokens_by_tag, handle_update_token_tags, handle_update_tokens, + handle_update_tokens_profile, }; mod checksum; pub use checksum::{handle_get_checksum, handle_get_hash, handle_get_timestamp_header}; diff --git a/src/chat/route/checksum.rs b/src/cursor/route/checksum.rs similarity index 100% rename from src/chat/route/checksum.rs rename to src/cursor/route/checksum.rs diff --git a/src/chat/route/health.rs b/src/cursor/route/health.rs similarity index 92% rename from src/chat/route/health.rs rename to src/cursor/route/health.rs index 95c2d9e..27b41d6 100644 --- a/src/chat/route/health.rs +++ b/src/cursor/route/health.rs @@ -8,14 +8,15 @@ use crate::{ ROUTE_HEALTH_PATH, ROUTE_LOGS_PATH, ROUTE_PROXIES_ADD_PATH, ROUTE_PROXIES_DELETE_PATH, ROUTE_PROXIES_GET_PATH, ROUTE_PROXIES_PATH, ROUTE_PROXIES_SET_GENERAL_PATH, ROUTE_PROXIES_UPDATE_PATH, ROUTE_README_PATH, ROUTE_ROOT_PATH, ROUTE_STATIC_PATH, - ROUTE_TOKENS_ADD_PATH, ROUTE_TOKENS_DELETE_PATH, ROUTE_TOKENS_GET_PATH, - ROUTE_TOKENS_PATH, ROUTE_TOKENS_PROFILE_UPDATE_PATH, ROUTE_TOKENS_TAGS_UPDATE_PATH, - ROUTE_TOKENS_UPDATE_PATH, ROUTE_USER_INFO_PATH, + ROUTE_TOKENS_ADD_PATH, ROUTE_TOKENS_BY_TAG_GET_PATH, ROUTE_TOKENS_DELETE_PATH, + ROUTE_TOKENS_GET_PATH, ROUTE_TOKENS_PATH, ROUTE_TOKENS_PROFILE_UPDATE_PATH, + ROUTE_TOKENS_TAGS_GET_PATH, ROUTE_TOKENS_TAGS_UPDATE_PATH, ROUTE_TOKENS_UPDATE_PATH, + ROUTE_USER_INFO_PATH, }, lazy::{AUTH_TOKEN, ROUTE_CHAT_PATH, ROUTE_MODELS_PATH, get_start_time}, model::{AppConfig, AppState, PageContent}, }, - chat::constant::Models, + cursor::constant::Models, common::model::{ ApiStatus, health::{CpuInfo, HealthCheckResponse, MemoryInfo, SystemInfo, SystemStats}, @@ -123,7 +124,9 @@ pub async fn handle_health( ROUTE_TOKENS_UPDATE_PATH, ROUTE_TOKENS_ADD_PATH, ROUTE_TOKENS_DELETE_PATH, + ROUTE_TOKENS_TAGS_GET_PATH, ROUTE_TOKENS_TAGS_UPDATE_PATH, + ROUTE_TOKENS_BY_TAG_GET_PATH, ROUTE_TOKENS_PROFILE_UPDATE_PATH, ROUTE_PROXIES_PATH, ROUTE_PROXIES_GET_PATH, diff --git a/src/chat/route/logs.rs b/src/cursor/route/logs.rs similarity index 100% rename from src/chat/route/logs.rs rename to src/cursor/route/logs.rs diff --git a/src/chat/route/page.rs b/src/cursor/route/page.rs similarity index 100% rename from src/chat/route/page.rs rename to src/cursor/route/page.rs diff --git a/src/chat/route/profile.rs b/src/cursor/route/profile.rs similarity index 92% rename from src/chat/route/profile.rs rename to src/cursor/route/profile.rs index b04f3fa..e3a03c9 100644 --- a/src/chat/route/profile.rs +++ b/src/cursor/route/profile.rs @@ -1,5 +1,5 @@ use crate::{ - app::model::proxy_pool::ProxyPool, chat::constant::ERR_NODATA, common::{ + app::model::proxy_pool::ProxyPool, cursor::constant::ERR_NODATA, common::{ model::userinfo::GetUserInfo, utils::{extract_token, get_token_profile}, } diff --git a/src/chat/route/proxies.rs b/src/cursor/route/proxies.rs similarity index 100% rename from src/chat/route/proxies.rs rename to src/cursor/route/proxies.rs diff --git a/src/chat/route/token.rs b/src/cursor/route/token.rs similarity index 99% rename from src/chat/route/token.rs rename to src/cursor/route/token.rs index e61507e..3b9b51b 100644 --- a/src/chat/route/token.rs +++ b/src/cursor/route/token.rs @@ -4,7 +4,7 @@ use crate::{ lazy::{AUTH_TOKEN, KEY_PREFIX}, model::{AppConfig, BuildKeyRequest, BuildKeyResponse, UsageCheckModelType}, }, - chat::config::{KeyConfig, key_config}, + cursor::config::{KeyConfig, key_config}, common::{ model::ApiStatus, utils::{ diff --git a/src/chat/route/tokens.rs b/src/cursor/route/tokens.rs similarity index 86% rename from src/chat/route/tokens.rs rename to src/cursor/route/tokens.rs index 0e99b71..a93f4e0 100644 --- a/src/chat/route/tokens.rs +++ b/src/cursor/route/tokens.rs @@ -4,9 +4,10 @@ use crate::{ TokenTagsUpdateRequest, TokenUpdateRequest, TokensDeleteRequest, TokensDeleteResponse, }, common::{ - model::{ApiStatus, ErrorResponse}, + model::{ApiStatus, ErrorResponse, NormalResponse}, utils::{ - generate_checksum_with_default, generate_checksum_with_repair, generate_hash, parse_token, validate_token + generate_checksum_with_default, generate_checksum_with_repair, generate_hash, + parse_token, validate_token, }, }, }; @@ -348,13 +349,57 @@ pub async fn handle_update_tokens_profile( )); } - let message = format!( - "已更新{}个令牌配置, {}个令牌更新失败", - updated_count, failed_count - ); + let message = format!("已更新{updated_count}个令牌配置, {failed_count}个令牌更新失败"); Ok(Json(CommonResponse { status: ApiStatus::Success, message: Some(message), })) } + +pub async fn handle_get_token_tags( + State(state): State>>, +) -> Result>>, StatusCode> { + let state = state.lock().await; + let tags: Vec<_> = state.token_manager.tags.iter().cloned().collect(); + let len = tags.len(); + + Ok(Json(NormalResponse { + status: ApiStatus::Success, + data: Some(tags), + message: Some(format!("获取到{len}个标签")), + })) +} + +pub async fn handle_get_tokens_by_tag( + State(state): State>>, + Json(tag): Json, +) -> Result, (StatusCode, Json)> { + let state = state.lock().await; + + match state.token_manager.get_tokens_by_tag(&tag) { + Ok(tokens) => { + let tokens_vec = tokens + .iter() + .map(|&t| t.clone()) + .collect::>(); + let tokens_count = tokens_vec.len(); + + Ok(Json(TokenInfoResponse { + status: ApiStatus::Success, + tokens: Some(tokens_vec), + tokens_count, + message: Some(format!("获取到{tokens_count}个标签为{tag}的令牌")), + })) + } + Err(e) => Err(( + StatusCode::BAD_REQUEST, + Json(ErrorResponse { + status: ApiStatus::Error, + code: None, + error: Some(e.to_string()), + message: Some(format!("标签\"{tag}\"不存在")), + }), + )), + } +} diff --git a/src/chat/service.rs b/src/cursor/service.rs similarity index 77% rename from src/chat/service.rs rename to src/cursor/service.rs index 01c26f3..233d5de 100644 --- a/src/chat/service.rs +++ b/src/cursor/service.rs @@ -10,19 +10,10 @@ use crate::{ cursor_api2_chat_web_url, }, model::{ - AppConfig, AppState, Chain, LogStatus, RequestLog, TimingInfo, TokenInfo, UsageCheck, - proxy_pool::ProxyPool, + AppConfig, AppState, Chain, ErrorInfo, LogStatus, OptionUsage, Prompt, RequestLog, + TimingInfo, TokenInfo, UsageCheck, proxy_pool::ProxyPool, }, }, - chat::{ - config::KeyConfig, - constant::{Models, USAGE_CHECK_MODELS}, - error::StreamError, - model::{ - ChatResponse, Choice, Delta, Message, MessageContent, ModelsResponse, Role, Usage, - }, - stream::{StreamDecoder, StreamMessage}, - }, common::{ client::{AiServiceRequest, build_request}, model::{ @@ -30,9 +21,19 @@ use crate::{ }, utils::{ TrimNewlines as _, format_time_ms, from_base64, generate_hash, get_available_models, - get_token_profile, tokeninfo_to_token, validate_token_and_checksum, + get_token_profile, get_token_usage, tokeninfo_to_token, validate_token_and_checksum, }, }, + cursor::{ + config::KeyConfig, + constant::{Models, USAGE_CHECK_MODELS}, + error::StreamError, + model::{ + ChatResponse, Choice, Delta, Message, MessageContent, ModelsResponse, Role, Usage, + }, + stream::{StreamDecoder, StreamMessage}, + }, + leak::intern_string, }; use axum::{ Json, @@ -116,7 +117,7 @@ pub async fn handle_models( from_base64(&token[*KEY_PREFIX_LEN..]) .and_then(|decoded_bytes| KeyConfig::decode(&decoded_bytes[..]).ok()) .and_then(|key_config| key_config.auth_token) - .and_then(|info| tokeninfo_to_token(info)) + .and_then(tokeninfo_to_token) .map(|(token, checksum, client)| { (token, checksum, None, client, GENERAL_TIMEZONE.name()) }) @@ -178,25 +179,25 @@ pub async fn handle_chat( headers: HeaderMap, Json(request): Json, ) -> Result, (StatusCode, Json)> { - let allow_claude = AppConfig::get_allow_claude(); - let is_search = request.model.ends_with("-online"); - let model_name = if is_search { - request.model[..request.model.len() - 7].to_string() - } else { - request.model.clone() - }; // 验证模型是否支持并获取模型信息 - let model = - if Models::exists(&model_name) || (allow_claude && request.model.starts_with("claude-")) { - Some(&model_name) + let model = { + let model_name = if is_search { + &request.model[..request.model.len() - 7] + } else { + &request.model + }; + + if let Some(model) = Models::find_id(model_name) { + model } else { return Err(( StatusCode::BAD_REQUEST, Json(ChatError::ModelNotSupported(request.model).to_json()), )); - }; + } + }; let request_time = chrono::Local::now(); @@ -304,7 +305,7 @@ pub async fn handle_chat( if log.token_info.token == auth_token { if let Some(profile) = &log.token_info.profile { if profile.stripe.membership_type == MembershipType::Free { - let is_premium = USAGE_CHECK_MODELS.contains(&model_name.as_str()); + let is_premium = USAGE_CHECK_MODELS.contains(&model); need_profile_check = if is_premium { profile .usage @@ -342,15 +343,10 @@ pub async fn handle_chat( current_id = next_id; // 如果需要获取用户使用情况,创建后台任务获取profile - if model - .map(|m| { - Model::is_usage_check( - m, - UsageCheck::from_proto(current_config.usage_check_models.as_ref()), - ) - }) - .unwrap_or(false) - { + if Model::is_usage_check( + model, + UsageCheck::from_proto(current_config.usage_check_models.as_ref()), + ) { let auth_token_clone = auth_token.clone(); let state_clone = state_clone.clone(); let log_id = next_id; @@ -393,7 +389,7 @@ pub async fn handle_chat( state.request_manager.request_logs.push(RequestLog { id: next_id, timestamp: request_time, - model: request.model.clone(), + model: intern_string(request.model), token_info: TokenInfo { token: auth_token.clone(), checksum: checksum.clone(), @@ -405,7 +401,7 @@ pub async fn handle_chat( timing: TimingInfo { total: 0.0 }, stream: request.stream, status: LogStatus::Pending, - error: None, + error: ErrorInfo::None, }); if !*IS_UNLIMITED_REQUEST_LOGS @@ -420,7 +416,7 @@ pub async fn handle_chat( // 将消息转换为hex格式 let hex_data = match super::adapter::encode_chat_message( request.messages, - &model_name, + model, current_config.disable_vision(), current_config.enable_slow_pool(), is_search, @@ -438,7 +434,7 @@ pub async fn handle_chat( .find(|log| log.id == current_id) { log.status = LogStatus::Failure; - log.error = Some(e.to_string()); + log.error = ErrorInfo::Error(intern_string(e.to_string())); } state.request_manager.active_requests -= 1; state.request_manager.error_requests += 1; @@ -453,8 +449,8 @@ pub async fn handle_chat( // 构建请求客户端 let trace_id = uuid::Uuid::new_v4(); - let client = build_request(AiServiceRequest { - client, + let req = build_request(AiServiceRequest { + client: client.clone(), auth_token: auth_token.as_str(), checksum: checksum.as_str(), client_key: client_key.as_str(), @@ -470,7 +466,7 @@ pub async fn handle_chat( }); let trace_id = trace_id.simple(); // 发送请求 - let response = client.body(hex_data).send().await; + let response = req.body(hex_data).send().await; // 处理请求结果 let response = match response { @@ -503,7 +499,7 @@ pub async fn handle_chat( .find(|log| log.id == current_id) { log.status = LogStatus::Failure; - log.error = Some(e.to_string()); + log.error = ErrorInfo::Error(intern_string(e.to_string())); } state.request_manager.active_requests -= 1; state.request_manager.error_requests += 1; @@ -536,16 +532,56 @@ pub async fn handle_chat( let is_start = Arc::new(AtomicBool::new(true)); let start_time = std::time::Instant::now(); let decoder = Arc::new(Mutex::new(StreamDecoder::new())); + let is_usage_sent = Arc::new(AtomicBool::new(false)); + let need_usage = if request.stream_options.is_some_and(|opt| opt.include_usage) { + Arc::new(Mutex::new(NeedUsage::Need { + client, + auth_token, + checksum, + client_key, + timezone, + is_pri, + })) + } else { + Arc::new(Mutex::new(NeedUsage::None)) + }; // 定义消息处理器的上下文结构体 struct MessageProcessContext<'a> { response_id: &'a str, - model: &'a str, + model: &'static str, is_start: &'a AtomicBool, start_time: std::time::Instant, state: &'a Mutex, current_id: u64, - need_usage: bool, + need_usage: &'a Mutex, + is_usage_sent: &'a AtomicBool, + } + + #[derive(Default)] + enum NeedUsage { + #[default] + None, + Need { + client: reqwest::Client, + auth_token: String, + checksum: String, + client_key: String, + timezone: &'static str, + is_pri: bool, + }, + } + + impl NeedUsage { + #[inline(always)] + const fn is_need(&self) -> bool { + matches!(*self, Self::Need { .. }) + } + + #[inline(always)] + fn take(&mut self) -> Self { + std::mem::take(self) + } } // 处理消息并生成响应数据的辅助函数 @@ -558,17 +594,13 @@ pub async fn handle_chat( for message in messages { match message { StreamMessage::Content(text) => { - let is_first = ctx.is_start.load(Ordering::SeqCst); + let is_first = ctx.is_start.load(Ordering::Acquire); let response = ChatResponse { id: ctx.response_id.to_string(), object: OBJECT_CHAT_COMPLETION_CHUNK, created: chrono::Utc::now().timestamp(), - model: if is_first { - Some(ctx.model.to_string()) - } else { - None - }, + model: if is_first { Some(ctx.model) } else { None }, choices: vec![Choice { index: 0, message: None, @@ -579,7 +611,7 @@ pub async fn handle_chat( None }, content: if is_first { - ctx.is_start.store(false, Ordering::SeqCst); + ctx.is_start.store(false, Ordering::Release); Some(text.trim_leading_newlines()) } else { Some(text) @@ -588,7 +620,7 @@ pub async fn handle_chat( logprobs: None, finish_reason: None, }], - usage: if ctx.need_usage { + usage: if ctx.need_usage.lock().await.is_need() { TriState::Null } else { TriState::None @@ -600,6 +632,62 @@ pub async fn handle_chat( serde_json::to_string(&response).unwrap() )); } + StreamMessage::Usage(usage_uuid) => { + if !ctx.is_usage_sent.load(Ordering::Acquire) { + if let NeedUsage::Need { + client, + auth_token, + checksum, + client_key, + timezone, + is_pri, + } = ctx.need_usage.lock().await.take() + { + let usage = get_token_usage( + client, + &auth_token, + &checksum, + &client_key, + timezone, + is_pri, + usage_uuid, + ) + .await; + if let Some(ref usage) = usage { + let mut state = ctx.state.lock().await; + if let Some(log) = state + .request_manager + .request_logs + .iter_mut() + .rev() + .find(|log| log.id == ctx.current_id) + { + if let Some(chain) = &mut log.chain { + chain.usage = OptionUsage::Uasge { + input: usage.prompt_tokens, + output: usage.completion_tokens, + } + } + } + } + let response = ChatResponse { + id: ctx.response_id.to_string(), + object: OBJECT_CHAT_COMPLETION_CHUNK, + created: chrono::Utc::now().timestamp(), + model: None, + choices: vec![], + usage: TriState::Some(usage.unwrap_or_default()), + }; + response_data.push_str(&format!( + "data: {}\n\n", + serde_json::to_string(&response).unwrap() + )); + ctx.is_usage_sent.store(true, Ordering::Release); + } + } else { + crate::debug_println!("usage is sent, but find {usage_uuid}"); + } + } StreamMessage::StreamEnd => { // 计算总时间和首次片段时间 let total_time = ctx.start_time.elapsed().as_secs_f64(); @@ -632,7 +720,7 @@ pub async fn handle_chat( logprobs: None, finish_reason: Some(FINISH_REASON_STOP.to_string()), }], - usage: if ctx.need_usage { + usage: if ctx.need_usage.lock().await.is_need() { TriState::Null } else { TriState::None @@ -642,7 +730,9 @@ pub async fn handle_chat( "data: {}\n\n", serde_json::to_string(&response).unwrap() )); - if ctx.need_usage { + if !ctx.is_usage_sent.load(Ordering::Acquire) + && ctx.need_usage.lock().await.is_need() + { let response = ChatResponse { id: ctx.response_id.to_string(), object: OBJECT_CHAT_COMPLETION_CHUNK, @@ -659,6 +749,7 @@ pub async fn handle_chat( "data: {}\n\n", serde_json::to_string(&response).unwrap() )); + ctx.is_usage_sent.store(true, Ordering::Release); }; } StreamMessage::Debug(debug_prompt) => { @@ -670,12 +761,14 @@ pub async fn handle_chat( .rev() .find(|log| log.id == ctx.current_id) { - if let Some(chain) = &mut log.chain { - chain.prompt.push_str(&debug_prompt); + if log.chain.is_some() { + crate::debug_println!("UB!1 {debug_prompt:?}"); + // chain.prompt.push_str(&debug_prompt); } else { log.chain = Some(Chain { - prompt: debug_prompt, + prompt: Prompt::new(debug_prompt), delays: vec![], + usage: OptionUsage::None, }); } } @@ -708,7 +801,11 @@ pub async fn handle_chat( .find(|log| log.id == current_id) { log.status = LogStatus::Failure; - log.error = Some(error_response.native_code()); + log.error = + ErrorInfo::Error(intern_string(error_response.native_code())); + if let Some(detail) = error_response.details() { + log.error.add_detail(&detail) + } log.timing.total = format_time_ms(start_time.elapsed().as_secs_f64()); state.request_manager.error_requests += 1; @@ -741,7 +838,7 @@ pub async fn handle_chat( .find(|log| log.id == current_id) { log.status = LogStatus::Failure; - log.error = Some("Empty stream response".to_string()); + log.error = ErrorInfo::Error(intern_string("Empty stream response")); state.request_manager.error_requests += 1; } } @@ -759,19 +856,15 @@ pub async fn handle_chat( let stream = stream .then({ let decoder = decoder.clone(); - let response_id = response_id.clone(); - let model = request.model.clone(); - let is_start = is_start.clone(); let state = state.clone(); - let need_usage = request.stream_options.is_some_and(|opt| opt.include_usage); move |chunk| { let decoder = decoder.clone(); let response_id = response_id.clone(); - let model = model.clone(); let is_start = is_start.clone(); let state = state.clone(); - let need_usage = need_usage; + let is_usage_sent = is_usage_sent.clone(); + let need_usage = need_usage.clone(); async move { let chunk = match chunk { @@ -784,12 +877,13 @@ pub async fn handle_chat( let ctx = MessageProcessContext { response_id: &response_id, - model: &model, + model, is_start: &is_start, start_time, state: &state, current_id, - need_usage, + need_usage: &need_usage, + is_usage_sent: &is_usage_sent, }; // 使用decoder处理chunk @@ -852,8 +946,9 @@ pub async fn handle_chat( chain.delays = decoder.lock().await.take_content_delays(); } else { log.chain = Some(Chain { - prompt: String::new(), + prompt: Prompt::Origin(String::new()), delays: decoder.lock().await.take_content_delays(), + usage: OptionUsage::None, }); } } @@ -873,7 +968,8 @@ pub async fn handle_chat( let mut decoder = StreamDecoder::new(); let mut full_text = String::with_capacity(1024); let mut stream = response.bytes_stream(); - let mut prompt = String::with_capacity(1024); + let mut prompt = Prompt::None; + let mut usage_uuid = String::new(); // 逐个处理chunks while let Some(chunk) = stream.next().await { @@ -895,8 +991,15 @@ pub async fn handle_chat( StreamMessage::Content(text) => { full_text.push_str(&text); } + StreamMessage::Usage(uuid) => { + usage_uuid = uuid; + } StreamMessage::Debug(debug_prompt) => { - prompt.push_str(&debug_prompt); + if prompt.is_none() { + prompt = Prompt::new(debug_prompt); + } else { + crate::debug_println!("UB!2 {debug_prompt:?}"); + } } _ => {} } @@ -904,12 +1007,44 @@ pub async fn handle_chat( } Err(StreamError::ChatError(error)) => { let error_response = error.into_error_response(); + { + let mut state = state.lock().await; + if let Some(log) = state + .request_manager + .request_logs + .iter_mut() + .rev() + .find(|log| log.id == current_id) + { + log.status = LogStatus::Failure; + log.error = + ErrorInfo::Error(intern_string(error_response.native_code())); + if let Some(detail) = error_response.details() { + log.error.add_detail(&detail) + } + state.request_manager.error_requests += 1; + } + } return Err(( error_response.status_code(), Json(error_response.into_common()), )); } Err(e) => { + { + let mut state = state.lock().await; + if let Some(log) = state + .request_manager + .request_logs + .iter_mut() + .rev() + .find(|log| log.id == current_id) + { + log.status = LogStatus::Failure; + log.error = ErrorInfo::Error(intern_string(e.to_string())); + state.request_manager.error_requests += 1; + } + } let error_response = ErrorResponse { status: ApiStatus::Error, code: Some(500), @@ -934,7 +1069,7 @@ pub async fn handle_chat( .find(|log| log.id == current_id) { log.status = LogStatus::Failure; - log.error = Some("Empty response received".to_string()); + log.error = ErrorInfo::Error(intern_string("Empty response received")); state.request_manager.error_requests += 1; } } @@ -944,11 +1079,34 @@ pub async fn handle_chat( )); } + let (usage1, usage2) = if !usage_uuid.is_empty() { + let result = get_token_usage( + client, + &auth_token, + &checksum, + &client_key, + timezone, + is_pri, + usage_uuid, + ) + .await; + let result2 = match result { + Some(ref usage) => OptionUsage::Uasge { + input: usage.prompt_tokens, + output: usage.completion_tokens, + }, + None => OptionUsage::None, + }; + (result, result2) + } else { + (None, OptionUsage::None) + }; + let response_data = ChatResponse { id: format!("chatcmpl-{trace_id}"), object: OBJECT_CHAT_COMPLETION, created: chrono::Utc::now().timestamp(), - model: Some(request.model), + model: Some(model), choices: vec![Choice { index: 0, message: Some(Message { @@ -959,11 +1117,7 @@ pub async fn handle_chat( logprobs: None, finish_reason: Some(FINISH_REASON_STOP.to_string()), }], - usage: TriState::Some(Usage { - prompt_tokens: 0, - completion_tokens: 0, - total_tokens: 0, - }), + usage: TriState::Some(usage1.unwrap_or_default()), }; { @@ -982,6 +1136,7 @@ pub async fn handle_chat( log.chain = Some(Chain { prompt, delays: decoder.take_content_delays(), + usage: usage2, }); } } @@ -996,3 +1151,11 @@ pub async fn handle_chat( .unwrap()) } } + +// pub async fn handle_completion( +// State(state): State>>, +// headers: HeaderMap, +// Json(request): Json, +// ) -> Result, (StatusCode, Json)> { + +// } diff --git a/src/chat/stream.rs b/src/cursor/stream.rs similarity index 100% rename from src/chat/stream.rs rename to src/cursor/stream.rs diff --git a/src/chat/stream/decoder.rs b/src/cursor/stream/decoder.rs similarity index 88% rename from src/chat/stream/decoder.rs rename to src/cursor/stream/decoder.rs index bbf4cc4..d45f116 100644 --- a/src/chat/stream/decoder.rs +++ b/src/cursor/stream/decoder.rs @@ -1,14 +1,15 @@ -use crate::chat::{ +use crate::common::utils::InstantExt as _; +use crate::cursor::{ aiserver::v1::{StreamChatResponse, WebReference}, error::{ChatError, StreamError}, }; -use crate::common::utils::InstantExt as _; use flate2::read::GzDecoder; use prost::Message; use std::io::Read; use std::time::Instant; // 解压gzip数据 +#[inline] fn decompress_gzip(data: &[u8]) -> Option> { let mut decoder = GzDecoder::new(data); let mut decompressed = Vec::new(); @@ -58,6 +59,8 @@ pub enum StreamMessage { ContentStart, // 消息内容 Content(String), + // 额度消耗 + Usage(String), // 流结束标志 StreamEnd, } @@ -225,6 +228,7 @@ impl StreamDecoder { Ok(messages) } + #[inline] fn process_message( &self, msg_type: u8, @@ -236,22 +240,25 @@ impl StreamDecoder { 2 => self.handle_json_message(msg_data), 3 => self.handle_gzip_json_message(msg_data), t => { - eprintln!("收到未知消息类型: {},请尝试联系开发者以获取支持", t); - crate::debug_println!("消息类型: {},消息内容: {}", t, hex::encode(msg_data)); + eprintln!("收到未知消息类型: {t},请尝试联系开发者以获取支持"); + crate::debug_println!("消息类型: {t},消息内容: {}", hex::encode(msg_data)); Ok(None) } } } + #[inline] fn handle_text_message(&self, msg_data: &[u8]) -> Result, StreamError> { if let Ok(response) = StreamChatResponse::decode(msg_data) { - // println!("[text] StreamChatResponse [hex: {}]: {:?}", hex::encode(msg_data), response); + // crate::debug_println!("[text] StreamChatResponse [hex: {}]: {:#?}", hex::encode(msg_data), response); if !response.text.is_empty() { Ok(Some(StreamMessage::Content(response.text))) } else if let Some(filled_prompt) = response.filled_prompt { Ok(Some(StreamMessage::Debug(filled_prompt))) } else if let Some(web_citation) = response.web_citation { Ok(Some(StreamMessage::WebReference(web_citation.references))) + } else if let Some(usage_uuid) = response.usage_uuid { + Ok(Some(StreamMessage::Usage(usage_uuid))) } else { Ok(None) } @@ -260,16 +267,19 @@ impl StreamDecoder { } } + #[inline] fn handle_gzip_message(&self, msg_data: &[u8]) -> Result, StreamError> { if let Some(text) = decompress_gzip(msg_data) { if let Ok(response) = StreamChatResponse::decode(&text[..]) { - // println!("[gzip] StreamChatResponse [hex: {}]: {:?}", hex::encode(msg_data), response); + // crate::debug_println!("[gzip] StreamChatResponse [hex: {}]: {:#?}", hex::encode(msg_data), response); if !response.text.is_empty() { Ok(Some(StreamMessage::Content(response.text))) } else if let Some(filled_prompt) = response.filled_prompt { Ok(Some(StreamMessage::Debug(filled_prompt))) } else if let Some(web_citation) = response.web_citation { Ok(Some(StreamMessage::WebReference(web_citation.references))) + } else if let Some(usage_uuid) = response.usage_uuid { + Ok(Some(StreamMessage::Usage(usage_uuid))) } else { Ok(None) } @@ -281,12 +291,13 @@ impl StreamDecoder { } } + #[inline] fn handle_json_message(&self, msg_data: &[u8]) -> Result, StreamError> { if msg_data.len() == 2 { return Ok(Some(StreamMessage::StreamEnd)); } if let Ok(text) = String::from_utf8(msg_data.to_vec()) { - // println!("[text] JSON消息 [hex: {}]: {}", hex::encode(msg_data), text); + // crate::debug_println!("[text] JSON消息 [hex: {}]: {}", hex::encode(msg_data), text); if let Ok(error) = serde_json::from_str::(&text) { return Err(StreamError::ChatError(error)); } @@ -294,6 +305,7 @@ impl StreamDecoder { Ok(None) } + #[inline] fn handle_gzip_json_message( &self, msg_data: &[u8], @@ -303,7 +315,7 @@ impl StreamDecoder { return Ok(Some(StreamMessage::StreamEnd)); } if let Ok(text) = String::from_utf8(text) { - // println!("[gzip] JSON消息 [hex: {}]: {}", hex::encode(msg_data), text); + // crate::debug_println!("[gzip] JSON消息 [hex: {}]: {}", hex::encode(msg_data), text); if let Ok(error) = serde_json::from_str::(&text) { return Err(StreamError::ChatError(error)); } @@ -343,8 +355,11 @@ mod tests { println!("流结束"); break; } + StreamMessage::Usage(msg) => { + println!("额度uuid: {msg}"); + } StreamMessage::Content(msg) => { - println!("消息内容: {}", msg); + println!("消息内容: {msg}"); } StreamMessage::WebReference(refs) => { println!("网页引用:"); @@ -356,7 +371,7 @@ mod tests { } } StreamMessage::Debug(prompt) => { - println!("调试信息: {}", prompt); + println!("调试信息: {prompt}"); } StreamMessage::ContentStart => { println!("流开始"); @@ -424,15 +439,18 @@ mod tests { for message in messages { match message { StreamMessage::StreamEnd => { - println!("流结束 [hex: {}]", hex_str); + println!("流结束 [hex: {hex_str}]"); should_break = true; break; } + StreamMessage::Usage(msg) => { + println!("额度uuid: {msg}"); + } StreamMessage::Content(msg) => { - println!("消息内容 [hex: {}]: {}", hex_str, msg); + println!("消息内容 [hex: {hex_str}]: {msg}"); } StreamMessage::WebReference(refs) => { - println!("网页引用 [hex: {}]:", hex_str); + println!("网页引用 [hex: {hex_str}]:"); for (i, web_ref) in refs.iter().enumerate() { println!( "{}. {} - {} - {}", @@ -441,10 +459,10 @@ mod tests { } } StreamMessage::Debug(prompt) => { - println!("调试信息 [hex: {}]: {}", hex_str, prompt); + println!("调试信息 [hex: {hex_str}]: {prompt}"); } StreamMessage::ContentStart => { - println!("流开始 [hex: {}]", hex_str); + println!("流开始 [hex: {hex_str}]"); } } } diff --git a/src/leak.rs b/src/leak.rs new file mode 100644 index 0000000..8f92d3a --- /dev/null +++ b/src/leak.rs @@ -0,0 +1,79 @@ +use parking_lot::Mutex; +use std::{collections::HashSet, sync::LazyLock}; + +#[derive(Default)] +struct StringPool { + pool: HashSet<&'static str>, +} + +impl StringPool { + // 驻留字符串 + fn intern(&mut self, s: &str) -> &'static str { + if let Some(&interned) = self.pool.get(s) { + interned + } else { + // 如果字符串不存在,使用 Box::leak 将其泄漏,并添加到 pool 中 + let leaked: &'static str = Box::leak(Box::from(s)); + self.pool.insert(leaked); + leaked + } + } +} + +// 全局 StringPool 实例 +static STRING_POOL: LazyLock> = + LazyLock::new(|| Mutex::new(StringPool::default())); + +pub fn intern_string>(s: S) -> &'static str { + STRING_POOL.lock().intern(s.as_ref()) +} + +// #[derive(Clone, Copy, PartialEq, Eq, Hash)] +// pub struct InternedString(&'static str); + +// impl InternedString { +// #[inline(always)] +// pub fn as_str(&self) -> &'static str { +// self.0 +// } +// } + +// impl Deref for InternedString { +// type Target = str; + +// #[inline(always)] +// fn deref(&self) -> &'static Self::Target { +// self.0 +// } +// } + +// impl Borrow for InternedString { +// #[inline(always)] +// fn borrow(&self) -> &'static str { +// self.0 +// } +// } + +// impl core::fmt::Debug for InternedString { +// #[inline(always)] +// fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +// self.0.fmt(f) +// } +// } + +// impl core::fmt::Display for InternedString { +// #[inline(always)] +// fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +// self.0.fmt(f) +// } +// } + +// impl serde::Serialize for InternedString { +// #[inline] +// fn serialize(&self, serializer: S) -> Result +// where +// S: serde::Serializer, +// { +// serializer.serialize_str(self.0) +// } +// } diff --git a/src/main.rs b/src/main.rs index 19726ab..7095b68 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod app; -mod chat; mod common; +mod cursor; +mod leak; use app::{ config::handle_config_update, @@ -11,9 +12,9 @@ use app::{ ROUTE_PROXIES_ADD_PATH, ROUTE_PROXIES_DELETE_PATH, ROUTE_PROXIES_GET_PATH, ROUTE_PROXIES_PATH, ROUTE_PROXIES_SET_GENERAL_PATH, ROUTE_PROXIES_UPDATE_PATH, ROUTE_README_PATH, ROUTE_ROOT_PATH, ROUTE_STATIC_PATH, ROUTE_TOKENS_ADD_PATH, - ROUTE_TOKENS_DELETE_PATH, ROUTE_TOKENS_GET_PATH, ROUTE_TOKENS_PATH, - ROUTE_TOKENS_PROFILE_UPDATE_PATH, ROUTE_TOKENS_TAGS_UPDATE_PATH, ROUTE_TOKENS_UPDATE_PATH, - ROUTE_USER_INFO_PATH, + ROUTE_TOKENS_BY_TAG_GET_PATH, ROUTE_TOKENS_DELETE_PATH, ROUTE_TOKENS_GET_PATH, + ROUTE_TOKENS_PATH, ROUTE_TOKENS_PROFILE_UPDATE_PATH, ROUTE_TOKENS_TAGS_GET_PATH, + ROUTE_TOKENS_TAGS_UPDATE_PATH, ROUTE_TOKENS_UPDATE_PATH, ROUTE_USER_INFO_PATH, }, lazy::{AUTH_TOKEN, ROUTE_CHAT_PATH, ROUTE_MODELS_PATH}, model::*, @@ -22,21 +23,21 @@ use axum::{ Router, middleware, routing::{get, post}, }; -use chat::{ +use common::utils::{parse_string_from_env, parse_usize_from_env}; +use cursor::{ middleware::admin_auth_middleware, route::{ handle_about, handle_add_proxy, handle_add_tokens, handle_api_page, handle_basic_calibration, handle_build_key, handle_build_key_page, handle_config_page, handle_delete_proxies, handle_delete_tokens, handle_env_example, handle_get_checksum, - handle_get_hash, handle_get_proxies, handle_get_timestamp_header, handle_get_tokens, - handle_health, handle_logs, handle_logs_post, handle_proxies_page, handle_readme, - handle_root, handle_set_general_proxy, handle_static, handle_tokens_page, - handle_update_proxies, handle_update_token_tags, handle_update_tokens, + handle_get_hash, handle_get_proxies, handle_get_timestamp_header, handle_get_token_tags, + handle_get_tokens, handle_get_tokens_by_tag, handle_health, handle_logs, handle_logs_post, + handle_proxies_page, handle_readme, handle_root, handle_set_general_proxy, handle_static, + handle_tokens_page, handle_update_proxies, handle_update_token_tags, handle_update_tokens, handle_update_tokens_profile, handle_user_info, }, service::{handle_chat, handle_models}, }; -use common::utils::{parse_string_from_env, parse_usize_from_env}; use std::sync::Arc; use tokio::signal; use tokio::sync::Mutex; @@ -65,7 +66,7 @@ async fn main() { AppConfig::init(); // 初始化应用状态 - let state = Arc::new(Mutex::new(AppState::new())); + let state = Arc::new(Mutex::new(AppState::new().await)); // 尝试加载保存的配置 if let Err(e) = AppConfig::load_saved_config() { @@ -154,10 +155,12 @@ async fn main() { .route(ROUTE_TOKENS_UPDATE_PATH, post(handle_update_tokens)) .route(ROUTE_TOKENS_ADD_PATH, post(handle_add_tokens)) .route(ROUTE_TOKENS_DELETE_PATH, post(handle_delete_tokens)) + .route(ROUTE_TOKENS_TAGS_GET_PATH, post(handle_get_token_tags)) .route( ROUTE_TOKENS_TAGS_UPDATE_PATH, post(handle_update_token_tags), ) + .route(ROUTE_TOKENS_BY_TAG_GET_PATH, post(handle_get_tokens_by_tag)) .route( ROUTE_TOKENS_PROFILE_UPDATE_PATH, post(handle_update_tokens_profile), @@ -210,6 +213,7 @@ async fn main() { #[cfg(feature = "__preview")] println!("当前是测试版,有问题及时反馈哦~"); + app::lazy::get_start_time(); let listener = tokio::net::TcpListener::bind(&addr) .await .unwrap_or_else(|e| { diff --git a/static/config.html b/static/config.html index f1c7869..fec99ed 100644 --- a/static/config.html +++ b/static/config.html @@ -66,8 +66,8 @@
- - @@ -137,7 +137,7 @@ }, vision_ability: document.getElementById('vision_ability').value, enable_slow_pool: parseBooleanFromString(document.getElementById('enable_slow_pool').value), - enable_all_claude: parseBooleanFromString(document.getElementById('enable_all_claude').value), + enable_long_context: parseBooleanFromString(document.getElementById('enable_long_context').value), usage_check_models: { type: document.getElementById('usage_check_models_type').value, content: document.getElementById('usage_check_models_list').value @@ -180,7 +180,7 @@ } // 对于布尔值,需要特殊处理 - if (key === 'enable_slow_pool' || key === 'enable_all_claude' || + if (key === 'enable_slow_pool' || key === 'enable_long_context' || key === 'enable_dynamic_key' || key === 'include_web_references') { // 只有当值不为null且与缓存不同时才添加 if (value !== null && value !== configCache[key]) { @@ -255,8 +255,8 @@ document.getElementById('vision_ability').value = visionValue; document.getElementById('enable_slow_pool').value = parseStringFromBoolean(data.data.enable_slow_pool, ''); - document.getElementById('enable_all_claude').value = - parseStringFromBoolean(data.data.enable_all_claude, ''); + document.getElementById('enable_long_context').value = + parseStringFromBoolean(data.data.enable_long_context, ''); // 处理使用量检查模型 const usageCheckModelsType = data.data.usage_check_models?.type || ''; @@ -279,7 +279,7 @@ content: pageContent || { type: 'default' }, vision_ability: visionValue, enable_slow_pool: data.data.enable_slow_pool, - enable_all_claude: data.data.enable_all_claude, + enable_long_context: data.data.enable_long_context, usage_check_models: { type: usageCheckModelsType, content: usageCheckModelsList.value diff --git a/static/logs.html b/static/logs.html index b771c8c..296b56f 100644 --- a/static/logs.html +++ b/static/logs.html @@ -1066,7 +1066,7 @@ ${new Date(log.timestamp).toLocaleString()} ${log.model}
- ${log.chain ? `
` : '-'} + ${log.chain ? `
` : '-'} ${formatTiming(log.timing.total)} ${log.stream ? '是' : '否'} ${log.status} @@ -1309,6 +1309,21 @@ function parsePrompt(promptStr) { if (!promptStr) return []; + // 尝试解析JSON格式的prompt + try { + const parsed = JSON.parse(promptStr); + + // 如果是已解析的格式 + if (Array.isArray(parsed)) { + return parsed.map(msg => ({ + role: msg.role, + content: msg.content + })); + } + } catch (e) { + // 如果解析JSON失败,说明是原始字符串格式,使用原来的解析逻辑 + } + const messages = []; const lines = promptStr.split('\n'); let currentRole = ''; @@ -1383,13 +1398,12 @@ .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); - - // 将HTML标签文本用引号包裹,使其更易读 - // return escaped.replace(/<(\/?[^>]+)>/g, '"<$1>"'); return escaped; } - return `${messages.map(msg => ``).join('')}
角色内容
${roleLabels[msg.role] || msg.role}${escapeHtml(msg.content).replace(/\n/g, '
')}
`; + return `${messages.map(msg => + `` + ).join('')}
角色内容
${roleLabels[msg.role] || msg.role}${escapeHtml(msg.content).replace(/\n/g, '
')}
`; } /** diff --git a/tools/set-token/src/main.rs b/tools/set-token/src/main.rs index 7410449..4089ad2 100644 --- a/tools/set-token/src/main.rs +++ b/tools/set-token/src/main.rs @@ -50,7 +50,7 @@ fn update_sqlite_tokens( })?; for row in rows { let (key, value) = row?; - println!("{}: {}", key, value); + println!("{key}: {value}"); } // 自动创建项并更新值