feat(tui): implement agent turn engine for background processing and enhance input handling

This commit is contained in:
asepharyana
2026-07-20 10:55:09 +07:00
parent da2ed6da25
commit 792695b65a
31 changed files with 603 additions and 153 deletions
+21 -3
View File
@@ -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())
}
}
}