42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use serde_json::{json, Value};
|
|||
|
|
use anyhow::{Result, anyhow};
|
||
|
|
use super::Tool;
|
||
|
|
use super::ToolCtx;
|
||
|
|
|
||
|
|
pub struct WorkflowRun;
|
||
|
|
|
||
|
|
impl Tool for WorkflowRun {
|
||
|
|
fn name(&self) -> &'static str {
|
||
|
|
"workflow_run"
|
||
|
|
}
|
||
|
|
|
||
|
|
fn description(&self) -> &'static str {
|
||
|
|
"Execute a workflow script by delegating to the workflow engine"
|
||
|
|
}
|
||
|
|
|
||
|
|
fn parameters(&self) -> Value {
|
||
|
|
json!({
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"script": {
|
||
|
|
"type": "string",
|
||
|
|
"description": "Workflow script content or path to a workflow file"
|
||
|
|
},
|
||
|
|
"args": {
|
||
|
|
"type": "object",
|
||
|
|
"description": "Optional arguments passed to the workflow script"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"required": ["script"]
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
fn run(&self, _ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||
|
|
let _script = args.get("script")
|
||
|
|
.and_then(|v| v.as_str())
|
||
|
|
.ok_or_else(|| anyhow!("missing required argument: script"))?;
|
||
|
|
let _workflow_args = args.get("args");
|
||
|
|
Ok("workflow delegated to workflow engine".to_string())
|
||
|
|
}
|
||
|
|
}
|