diff --git a/.gitignore b/.gitignore index fb083cf..2d51951 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ claude-server.tar dist .task /local-docs/ -bin +/bin/ logs/ cursor-server.db cursor-server.db-shm diff --git a/server/src/bin/cursor-server.rs b/server/src/bin/cursor-server.rs new file mode 100644 index 0000000..0d88107 --- /dev/null +++ b/server/src/bin/cursor-server.rs @@ -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 +} diff --git a/server/src/control/service.rs b/server/src/control/service.rs index 8642fca..f5e625e 100644 --- a/server/src/control/service.rs +++ b/server/src/control/service.rs @@ -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) } } diff --git a/server/src/cursor/tools/result/local.rs b/server/src/cursor/tools/result/local.rs index 95f920c..24d9a94 100644 --- a/server/src/cursor/tools/result/local.rs +++ b/server/src/cursor/tools/result/local.rs @@ -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() -} diff --git a/server/src/cursor/tools/runtime.rs b/server/src/cursor/tools/runtime.rs index 496ed86..6175f29 100644 --- a/server/src/cursor/tools/runtime.rs +++ b/server/src/cursor/tools/runtime.rs @@ -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 -} diff --git a/server/tests/subagent_protocol.rs b/server/tests/subagent_protocol.rs index f4e0bc0..e2da9c1 100644 --- a/server/tests/subagent_protocol.rs +++ b/server/tests/subagent_protocol.rs @@ -16,10 +16,7 @@ use cursor_server::{ #[test] fn task_keeps_wire_type_model_parent_and_background_fields() { let mut context = context(); - context.subagent_models.insert( - "cursor-guide".into(), - SubagentModel::Model("guide-model".into()), - ); + context.subagent_model = Some(SubagentModel::Model("guide-model".into())); let call = task_call(serde_json::json!({ "description": "guide", "prompt": "inspect", @@ -105,9 +102,7 @@ fn task_renders_general_typed_and_custom_subagent_types_without_aliases() { #[test] fn disabled_task_model_is_left_for_the_model_visible_reminder() { let mut context = context(); - context - .subagent_models - .insert("security-review".into(), SubagentModel::Disabled); + context.subagent_model = Some(SubagentModel::Disabled); let call = task_call(serde_json::json!({ "description": "review", "prompt": "inspect", @@ -192,7 +187,7 @@ fn context() -> ExecContext { conversation_id: "child".into(), root_conversation_id: "root".into(), default_subagent_model: "parent-model".into(), - subagent_models: HashMap::new(), + subagent_model: None, allow_subagents: true, subagents_disabled: false, terminals_folder: "/tmp/terminals".into(), diff --git a/server/tests/tool_loop.rs b/server/tests/tool_loop.rs index 5e15d69..e85b622 100644 --- a/server/tests/tool_loop.rs +++ b/server/tests/tool_loop.rs @@ -42,7 +42,7 @@ fn exec_context() -> ExecContext { conversation_id: "conversation".into(), root_conversation_id: "conversation".into(), default_subagent_model: "model".into(), - subagent_models: std::collections::HashMap::new(), + subagent_model: None, terminals_folder: "/tmp/terminals".into(), admin_command_denylist: Vec::new(), allow_subagents: true,