feat(tui): implement agent turn engine for background processing and enhance input handling
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use crate::tools::{Tool, ToolCtx};
|
||||
use anyhow::Result;
|
||||
use serde_json::{json, Value};
|
||||
use tracing::info;
|
||||
|
||||
pub struct PlanEnter;
|
||||
|
||||
@@ -51,11 +52,28 @@ impl Tool for PlanReady {
|
||||
fn parameters(&self) -> Value {
|
||||
json!({
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
"properties": {
|
||||
"plan": {
|
||||
"type": "string",
|
||||
"description": "The final plan content"
|
||||
}
|
||||
},
|
||||
"required": ["plan"]
|
||||
})
|
||||
}
|
||||
|
||||
fn run(&self, _ctx: &ToolCtx, _args: &Value) -> Result<String> {
|
||||
Ok("Plan is ready. Starting execution.".to_string())
|
||||
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||||
let plan_content = crate::tools::arg_str(args, "plan")?;
|
||||
info!("plan ready: {} chars", plan_content.len());
|
||||
// Persist the plan to session directory for reference
|
||||
let plan_dir = ctx.session_dir.join("plans");
|
||||
if std::fs::create_dir_all(&plan_dir).is_ok() {
|
||||
let filename = format!("plan-{}.md", chrono::Utc::now().format("%Y%m%d_%H%M%S"));
|
||||
let path = plan_dir.join(&filename);
|
||||
let _ = std::fs::write(&path, &plan_content);
|
||||
Ok(format!("Plan saved to {filename}. Starting execution."))
|
||||
} else {
|
||||
Ok("Plan is ready. Starting execution.".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user