mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-05 04:07:36 +08:00
fix: restore service entrypoint and clean checks
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
use cursor_server::{App, Config, Result};
|
||||
use tracing_subscriber::prelude::*;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
tracing_subscriber::registry()
|
||||
.with(
|
||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||
.unwrap_or_else(|_| "cursor_server=info".into()),
|
||||
)
|
||||
.with(tracing_subscriber::fmt::layer())
|
||||
.init();
|
||||
|
||||
App::new(Config::from_env()?).await?.serve().await
|
||||
}
|
||||
@@ -695,7 +695,7 @@ fn estimate_output_tokens(output: &str) -> u64 {
|
||||
} else if output.is_empty() {
|
||||
0
|
||||
} else {
|
||||
((output.chars().count() as u64) + 3) / 4
|
||||
(output.chars().count() as u64).div_ceil(4)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,13 @@ fn text(value: &Value, name: &str) -> String {
|
||||
.into()
|
||||
}
|
||||
|
||||
fn normalized(name: &str) -> String {
|
||||
name.chars()
|
||||
.filter(|character| character.is_ascii_alphanumeric())
|
||||
.flat_map(char::to_lowercase)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -203,10 +210,3 @@ mod tests {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn normalized(name: &str) -> String {
|
||||
name.chars()
|
||||
.filter(|character| character.is_ascii_alphanumeric())
|
||||
.flat_map(char::to_lowercase)
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -346,6 +346,13 @@ impl CursorToolRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn now_ms() -> u64 {
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_millis() as u64
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -420,10 +427,3 @@ mod tests {
|
||||
.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn now_ms() -> u64 {
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_millis() as u64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user