mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-06 05:12:03 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f87357681 |
Generated
+1
-1
@@ -1128,7 +1128,7 @@ checksum = "52560adf09603e58c9a7ee1fe1dcb95a16927b17c127f0ac02d6e768a0e25bc1"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cursor-byok-desktop"
|
name = "cursor-byok-desktop"
|
||||||
version = "0.1.0-beta.10"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"cursor-server",
|
"cursor-server",
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "cursor-byok-desktop",
|
"name": "cursor-byok-desktop",
|
||||||
"version": "0.1.0-beta.10",
|
"version": "0.1.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "cursor-byok-desktop",
|
"name": "cursor-byok-desktop",
|
||||||
"version": "0.1.0-beta.10",
|
"version": "0.1.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@floating-ui/dom": "^1.8.0",
|
"@floating-ui/dom": "^1.8.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cursor-byok-desktop",
|
"name": "cursor-byok-desktop",
|
||||||
"version": "0.1.0-beta.10",
|
"version": "0.1.1",
|
||||||
"description": "Cursor BYOK desktop management application",
|
"description": "Cursor BYOK desktop management application",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cursor-byok-desktop"
|
name = "cursor-byok-desktop"
|
||||||
version = "0.1.0-beta.10"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Cursor BYOK",
|
"productName": "Cursor BYOK",
|
||||||
"version": "0.1.0-beta.10",
|
"version": "0.1.1",
|
||||||
"identifier": "dev.cursorbyok.desktop",
|
"identifier": "dev.cursorbyok.desktop",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|||||||
@@ -34,27 +34,33 @@ pub fn request(id: u32, call: &ToolCall, context: &ExecContext) -> Result<pb::Ag
|
|||||||
.map(|v| v as i32)
|
.map(|v| v as i32)
|
||||||
};
|
};
|
||||||
let message = match normalize(&call.name).as_str() {
|
let message = match normalize(&call.name).as_str() {
|
||||||
"shell" => Message::ShellStreamArgs(pb::ShellArgs {
|
"shell" => {
|
||||||
command: string("command")?,
|
let command = string("command")?;
|
||||||
working_directory: optional_string("working_directory").unwrap_or_default(),
|
let (simple_commands, parsing_result) = shell_command_metadata(&command);
|
||||||
timeout: shell_timeout(call)?,
|
Message::ShellStreamArgs(pb::ShellArgs {
|
||||||
tool_call_id: call.call_id.clone(),
|
command,
|
||||||
file_output_threshold_bytes: Some(40_000),
|
working_directory: optional_string("working_directory").unwrap_or_default(),
|
||||||
timeout_behavior: pb::TimeoutBehavior::Background as i32,
|
timeout: shell_timeout(call)?,
|
||||||
hard_timeout: Some(86_400_000),
|
tool_call_id: call.call_id.clone(),
|
||||||
description: optional_string("description"),
|
simple_commands,
|
||||||
output_notification: shell_notification(call)?,
|
parsing_result,
|
||||||
smart_mode_approval: smart_mode_approval(
|
file_output_threshold_bytes: Some(40_000),
|
||||||
call,
|
timeout_behavior: pb::TimeoutBehavior::Background as i32,
|
||||||
"request_smart_mode_approval",
|
hard_timeout: Some(86_400_000),
|
||||||
"smart_mode_block_reason",
|
description: optional_string("description"),
|
||||||
)?,
|
output_notification: shell_notification(call)?,
|
||||||
requested_sandbox_policy: shell_sandbox_policy(call),
|
smart_mode_approval: smart_mode_approval(
|
||||||
close_stdin: true,
|
call,
|
||||||
conversation_id: Some(context.conversation_id.clone()),
|
"request_smart_mode_approval",
|
||||||
admin_command_denylist: context.admin_command_denylist.clone(),
|
"smart_mode_block_reason",
|
||||||
..Default::default()
|
)?,
|
||||||
}),
|
requested_sandbox_policy: shell_sandbox_policy(call),
|
||||||
|
close_stdin: true,
|
||||||
|
conversation_id: Some(context.conversation_id.clone()),
|
||||||
|
admin_command_denylist: context.admin_command_denylist.clone(),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
}
|
||||||
"read" => Message::ReadArgs(pb::ReadArgs {
|
"read" => Message::ReadArgs(pb::ReadArgs {
|
||||||
path: string("path")?,
|
path: string("path")?,
|
||||||
tool_call_id: call.call_id.clone(),
|
tool_call_id: call.call_id.clone(),
|
||||||
@@ -368,10 +374,7 @@ pub fn abort(id: u32) -> pb::AgentServerMessage {
|
|||||||
|
|
||||||
fn shell_sandbox_policy(call: &ToolCall) -> Option<pb::SandboxPolicy> {
|
fn shell_sandbox_policy(call: &ToolCall) -> Option<pb::SandboxPolicy> {
|
||||||
let permissions = call.arguments.get("required_permissions")?.as_array()?;
|
let permissions = call.arguments.get("required_permissions")?.as_array()?;
|
||||||
let perms: Vec<&str> = permissions
|
let perms: Vec<&str> = permissions.iter().filter_map(Value::as_str).collect();
|
||||||
.iter()
|
|
||||||
.filter_map(Value::as_str)
|
|
||||||
.collect();
|
|
||||||
if perms.contains(&"all") {
|
if perms.contains(&"all") {
|
||||||
Some(pb::SandboxPolicy {
|
Some(pb::SandboxPolicy {
|
||||||
r#type: pb::sandbox_policy::Type::InsecureNone as i32,
|
r#type: pb::sandbox_policy::Type::InsecureNone as i32,
|
||||||
@@ -389,6 +392,33 @@ fn shell_sandbox_policy(call: &ToolCall) -> Option<pb::SandboxPolicy> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn shell_command_metadata(command: &str) -> (Vec<String>, Option<pb::ShellCommandParsingResult>) {
|
||||||
|
let command = command.trim();
|
||||||
|
let mut parts = command.split_whitespace();
|
||||||
|
let Some(name) = parts.next() else {
|
||||||
|
return (Vec::new(), None);
|
||||||
|
};
|
||||||
|
let args = parts
|
||||||
|
.map(
|
||||||
|
|value| pb::shell_command_parsing_result::ExecutableCommandArg {
|
||||||
|
r#type: "word".into(),
|
||||||
|
value: value.into(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.collect();
|
||||||
|
(
|
||||||
|
vec![command.into()],
|
||||||
|
Some(pb::ShellCommandParsingResult {
|
||||||
|
executable_commands: vec![pb::shell_command_parsing_result::ExecutableCommand {
|
||||||
|
name: name.into(),
|
||||||
|
args,
|
||||||
|
full_text: command.into(),
|
||||||
|
}],
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn shell_timeout(call: &ToolCall) -> Result<i32> {
|
fn shell_timeout(call: &ToolCall) -> Result<i32> {
|
||||||
let value = call
|
let value = call
|
||||||
.arguments
|
.arguments
|
||||||
|
|||||||
@@ -398,6 +398,21 @@ async fn shell_uses_background_timeout_and_preserves_stream_identity() {
|
|||||||
assert!(args.close_stdin);
|
assert!(args.close_stdin);
|
||||||
assert_eq!(args.conversation_id.as_deref(), Some("conversation"));
|
assert_eq!(args.conversation_id.as_deref(), Some("conversation"));
|
||||||
assert_eq!(args.file_output_threshold_bytes, Some(40_000));
|
assert_eq!(args.file_output_threshold_bytes, Some(40_000));
|
||||||
|
assert_eq!(args.simple_commands, ["python3 -m http.server 8000"]);
|
||||||
|
let parsing = args.parsing_result.as_ref().unwrap();
|
||||||
|
assert!(!parsing.parsing_failed);
|
||||||
|
assert_eq!(parsing.executable_commands.len(), 1);
|
||||||
|
let executable = &parsing.executable_commands[0];
|
||||||
|
assert_eq!(executable.name, "python3");
|
||||||
|
assert_eq!(executable.full_text, "python3 -m http.server 8000");
|
||||||
|
assert_eq!(
|
||||||
|
executable
|
||||||
|
.args
|
||||||
|
.iter()
|
||||||
|
.map(|argument| (argument.r#type.as_str(), argument.value.as_str()))
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
[("word", "-m"), ("word", "http.server"), ("word", "8000")]
|
||||||
|
);
|
||||||
|
|
||||||
let rendered = cursor_server::cursor::interaction::render_tool_call(&shell, false).unwrap();
|
let rendered = cursor_server::cursor::interaction::render_tool_call(&shell, false).unwrap();
|
||||||
let Some(pb::tool_call::Tool::ShellToolCall(rendered)) = rendered.tool else {
|
let Some(pb::tool_call::Tool::ShellToolCall(rendered)) = rendered.tool else {
|
||||||
|
|||||||
Reference in New Issue
Block a user