Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/terminator-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ path = "src/bin/cargo-terminator.rs"
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.140"
serde_yaml = "0.9"
clap = { version = "4.4", features = ["derive", "env"] }
tokio = { version = "1", features = [
"rt",
Expand Down
22 changes: 8 additions & 14 deletions crates/terminator-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct McpRunArgs {
#[clap(long, short = 'c', conflicts_with = "url")]
command: Option<String>,

/// Input source - can be a GitHub gist URL, raw gist URL, or local file path (JSON/YAML)
/// Input source - can be a GitHub gist URL, raw gist URL, or local file path (JSON)
input: String,

/// Input type (auto-detected by default)
Expand Down Expand Up @@ -1491,7 +1491,7 @@ async fn run_workflow(transport: mcp_client::Transport, args: McpRunArgs) -> any
return Ok(());
}

// Fetch workflow content (for YAML workflows)
// Fetch workflow content (for workflows)
let content = match resolved_type {
InputType::File => {
info!("Reading local file");
Expand Down Expand Up @@ -1711,7 +1711,7 @@ async fn run_workflow(transport: mcp_client::Transport, args: McpRunArgs) -> any
Ok(())
}

/// Extract cron expression from workflow YAML
/// Extract cron expression from workflow
fn extract_cron_from_workflow(workflow: &Value) -> Option<String> {
// Primary format: cron field at root level (simpler format)
if let Some(cron) = workflow.get("cron") {
Expand Down Expand Up @@ -1914,7 +1914,7 @@ async fn run_workflow_once(
return Ok(());
}

// Fetch workflow content (for YAML workflows)
// Fetch workflow content (for workflows)
let content = match resolved_type {
InputType::File => read_local_file(&args.input).await?,
InputType::Gist => {
Expand Down Expand Up @@ -2164,8 +2164,8 @@ fn parse_workflow_content(content: &str) -> anyhow::Result<serde_json::Value> {
}
}

// Strategy 2: Try direct YAML workflow
if let Ok(val) = serde_yaml::from_str::<serde_json::Value>(content) {
// Strategy 2: Try as wrapper object
if let Ok(val) = serde_json::from_str::<serde_json::Value>(content) {
// Check if it's a valid workflow (has steps field)
if val.get("steps").is_some() {
return Ok(val);
Expand All @@ -2184,18 +2184,12 @@ fn parse_workflow_content(content: &str) -> anyhow::Result<serde_json::Value> {
}
}

// Strategy 4: Try parsing as YAML wrapper first, then extract
if let Ok(val) = serde_yaml::from_str::<serde_json::Value>(content) {
if let Some(extracted) = extract_workflow_from_wrapper(&val)? {
return Ok(extracted);
}
}

Err(anyhow::anyhow!(
"Unable to parse content as JSON or YAML workflow or wrapper object. Content must either be:\n\
"Unable to parse content as JSON workflow or wrapper object. Content must either be:\n\
1. A workflow with 'steps' field\n\
2. A wrapper object with tool_name='execute_sequence' and 'arguments' field\n\
3. Valid JSON or YAML format"
3. Valid JSON format"
))
}

Expand Down
80 changes: 5 additions & 75 deletions crates/terminator-cli/src/mcp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ pub async fn execute_command_with_progress_and_retry(
Err(e) => {
let error_str = e.to_string();
// TypeScript workflows: don't retry on timeout (should handle retries internally)
// YAML workflows: retry on timeout
// Workflows: retry on timeout
// Other tools: retry on timeout
let is_retryable = if is_typescript_workflow {
// TypeScript workflows should handle retries internally
Expand All @@ -1118,7 +1118,7 @@ pub async fn execute_command_with_progress_and_retry(
|| error_str.contains("503")
|| error_str.contains("504")
} else {
// YAML workflows and other tools can retry on timeout
// Workflows can retry on timeout
error_str.contains("401")
|| error_str.contains("Unauthorized")
|| error_str.contains("500")
Expand Down Expand Up @@ -1271,7 +1271,7 @@ pub async fn execute_command_with_progress_and_retry(
Err(e) => {
let error_str = e.to_string();
// TypeScript workflows: don't retry on timeout (should handle retries internally)
// YAML workflows: retry on timeout
// Workflows: retry on timeout
// Other tools: retry on timeout
let is_retryable = if is_typescript_workflow {
// TypeScript workflows should handle retries internally
Expand All @@ -1282,7 +1282,7 @@ pub async fn execute_command_with_progress_and_retry(
|| error_str.contains("503")
|| error_str.contains("504")
} else {
// YAML workflows and other tools can retry on timeout
// Workflows can retry on timeout
error_str.contains("401")
|| error_str.contains("Unauthorized")
|| error_str.contains("500")
Expand Down Expand Up @@ -1370,23 +1370,6 @@ mod tests {

assert!(is_js, "Should detect .js file as JavaScript workflow");

// Test YAML workflow detection (URL ends with .yml or .yaml)
let args_yaml = serde_json::json!({
"url": "file:///path/to/workflow.yml"
});
let args_map_yaml = args_yaml.as_object().cloned();

let is_yaml = args_map_yaml
.as_ref()
.and_then(|args| args.get("url"))
.and_then(|url| url.as_str())
.map(|url| url.ends_with(".ts") || url.ends_with(".js"))
.unwrap_or(false);

assert!(
!is_yaml,
"Should NOT detect .yml file as TypeScript workflow"
);

// Test no URL provided
let args_no_url = serde_json::json!({
Expand Down Expand Up @@ -1419,7 +1402,7 @@ mod tests {
|| error_str.contains("503")
|| error_str.contains("504")
} else {
// YAML workflows and other tools can retry on timeout
// Workflows can retry on timeout
error_str.contains("401")
|| error_str.contains("Unauthorized")
|| error_str.contains("500")
Expand Down Expand Up @@ -1460,57 +1443,4 @@ mod tests {
);
}

#[test]
fn test_retry_logic_for_yaml_workflows() {
// Test that timeout errors ARE retryable for YAML workflows
let error_str = "timeout waiting for element"; // lowercase to match contains() check
let is_typescript_workflow = false;

let is_retryable = if is_typescript_workflow {
error_str.contains("401")
|| error_str.contains("Unauthorized")
|| error_str.contains("500")
|| error_str.contains("502")
|| error_str.contains("503")
|| error_str.contains("504")
} else {
error_str.contains("401")
|| error_str.contains("Unauthorized")
|| error_str.contains("500")
|| error_str.contains("502")
|| error_str.contains("503")
|| error_str.contains("504")
|| error_str.contains("timeout")
};

assert!(
is_retryable,
"YAML workflows SHOULD retry on timeout errors"
);

// Test that HTTP errors ARE retryable for YAML workflows
let error_str_502 = "502 Bad Gateway";

let is_retryable_502 = if is_typescript_workflow {
error_str_502.contains("401")
|| error_str_502.contains("Unauthorized")
|| error_str_502.contains("500")
|| error_str_502.contains("502")
|| error_str_502.contains("503")
|| error_str_502.contains("504")
} else {
error_str_502.contains("401")
|| error_str_502.contains("Unauthorized")
|| error_str_502.contains("500")
|| error_str_502.contains("502")
|| error_str_502.contains("503")
|| error_str_502.contains("504")
|| error_str_502.contains("timeout")
};

assert!(
is_retryable_502,
"YAML workflows SHOULD retry on HTTP 502 errors"
);
}
}
1 change: 0 additions & 1 deletion crates/terminator-mcp-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ hostname = "0.4"
reqwest = { version = "0.12.5", features = ["json", "blocking"] }

# YAML parsing support
serde_yaml = "0.9"

# File search support for search_terminator_api tools
glob = "0.3"
Expand Down
4 changes: 2 additions & 2 deletions crates/terminator-mcp-agent/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod expression_eval;
pub mod helpers;
pub mod mcp_types;
pub mod omniparser;
pub mod output_parser;

pub mod prompt;
pub mod scripting_engine;
pub mod sentry;
Expand All @@ -17,7 +17,7 @@ pub mod tool_logging;
pub mod tree_formatter;
pub mod utils;
pub mod vision;
pub mod workflow_format;

pub mod workflow_typescript;

// Re-export ui_tree_diff from terminator crate (single source of truth)
Expand Down
Loading
Loading