Refactor agent runtime: state machine, feedback processing, execution log

- Add state.rs with AgentState/Step/StepStatus/AgentPhase as single source of truth
- Extract prompts to markdown files loaded via include_str!
- Replace plan_steps table with execution_log + agent_state_snapshots
- Implement user feedback processing with docker-build-cache plan diff:
  load snapshot → LLM revise_plan → diff (title, description) → invalidate from first mismatch → resume
- run_agent_loop accepts optional initial_state for mid-execution resume
- Broadcast plan step status (done/running/pending) to frontend on step transitions
- Rewrite frontend types/components to match new API (ExecutionLogEntry, PlanStepInfo with status)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 08:54:43 +00:00
parent 7f6dafeab6
commit 46424cfbc4
16 changed files with 910 additions and 992 deletions

View File

@@ -9,7 +9,7 @@ use axum::{
use serde::Deserialize;
use crate::AppState;
use crate::agent::AgentEvent;
use crate::db::{Workflow, PlanStep, Comment};
use crate::db::{Workflow, ExecutionLogEntry, Comment};
use super::{ApiResult, db_err};
#[derive(serde::Serialize)]
@@ -77,9 +77,9 @@ async fn create_workflow(
async fn list_steps(
State(state): State<Arc<AppState>>,
Path(workflow_id): Path<String>,
) -> ApiResult<Vec<PlanStep>> {
sqlx::query_as::<_, PlanStep>(
"SELECT * FROM plan_steps WHERE workflow_id = ? ORDER BY step_order"
) -> ApiResult<Vec<ExecutionLogEntry>> {
sqlx::query_as::<_, ExecutionLogEntry>(
"SELECT * FROM execution_log WHERE workflow_id = ? ORDER BY created_at"
)
.bind(&workflow_id)
.fetch_all(&state.db.pool)