mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-10-04 02:52:55 +08:00
fix: restore Windows shell parsing metadata
This commit is contained in:
Generated
+1
-1
@@ -1128,7 +1128,7 @@ checksum = "52560adf09603e58c9a7ee1fe1dcb95a16927b17c127f0ac02d6e768a0e25bc1"
|
||||
|
||||
[[package]]
|
||||
name = "cursor-byok-desktop"
|
||||
version = "0.1.0-beta.10"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"cursor-server",
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "cursor-byok-desktop",
|
||||
"version": "0.1.0-beta.10",
|
||||
"version": "0.1.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cursor-byok-desktop",
|
||||
"version": "0.1.0-beta.10",
|
||||
"version": "0.1.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@floating-ui/dom": "^1.8.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cursor-byok-desktop",
|
||||
"version": "0.1.0-beta.10",
|
||||
"version": "0.1.1",
|
||||
"description": "Cursor BYOK desktop management application",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cursor-byok-desktop"
|
||||
version = "0.1.0-beta.10"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Cursor BYOK",
|
||||
"version": "0.1.0-beta.10",
|
||||
"version": "0.1.1",
|
||||
"identifier": "dev.cursorbyok.desktop",
|
||||
"build": {
|
||||
"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)
|
||||
};
|
||||
let message = match normalize(&call.name).as_str() {
|
||||
"shell" => Message::ShellStreamArgs(pb::ShellArgs {
|
||||
command: string("command")?,
|
||||
working_directory: optional_string("working_directory").unwrap_or_default(),
|
||||
timeout: shell_timeout(call)?,
|
||||
tool_call_id: call.call_id.clone(),
|
||||
file_output_threshold_bytes: Some(40_000),
|
||||
timeout_behavior: pb::TimeoutBehavior::Background as i32,
|
||||
hard_timeout: Some(86_400_000),
|
||||
description: optional_string("description"),
|
||||
output_notification: shell_notification(call)?,
|
||||
smart_mode_approval: smart_mode_approval(
|
||||
call,
|
||||
"request_smart_mode_approval",
|
||||
"smart_mode_block_reason",
|
||||
)?,
|
||||
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()
|
||||
}),
|
||||
"shell" => {
|
||||
let command = string("command")?;
|
||||
let (simple_commands, parsing_result) = shell_command_metadata(&command);
|
||||
Message::ShellStreamArgs(pb::ShellArgs {
|
||||
command,
|
||||
working_directory: optional_string("working_directory").unwrap_or_default(),
|
||||
timeout: shell_timeout(call)?,
|
||||
tool_call_id: call.call_id.clone(),
|
||||
simple_commands,
|
||||
parsing_result,
|
||||
file_output_threshold_bytes: Some(40_000),
|
||||
timeout_behavior: pb::TimeoutBehavior::Background as i32,
|
||||
hard_timeout: Some(86_400_000),
|
||||
description: optional_string("description"),
|
||||
output_notification: shell_notification(call)?,
|
||||
smart_mode_approval: smart_mode_approval(
|
||||
call,
|
||||
"request_smart_mode_approval",
|
||||
"smart_mode_block_reason",
|
||||
)?,
|
||||
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 {
|
||||
path: string("path")?,
|
||||
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> {
|
||||
let permissions = call.arguments.get("required_permissions")?.as_array()?;
|
||||
let perms: Vec<&str> = permissions
|
||||
.iter()
|
||||
.filter_map(Value::as_str)
|
||||
.collect();
|
||||
let perms: Vec<&str> = permissions.iter().filter_map(Value::as_str).collect();
|
||||
if perms.contains(&"all") {
|
||||
Some(pb::SandboxPolicy {
|
||||
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> {
|
||||
let value = call
|
||||
.arguments
|
||||
|
||||
@@ -398,6 +398,21 @@ async fn shell_uses_background_timeout_and_preserves_stream_identity() {
|
||||
assert!(args.close_stdin);
|
||||
assert_eq!(args.conversation_id.as_deref(), Some("conversation"));
|
||||
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 Some(pb::tool_call::Tool::ShellToolCall(rendered)) = rendered.tool else {
|
||||
|
||||
Reference in New Issue
Block a user