| 713 | } |
| 714 | |
| 715 | pub async fn execute(&self, program: &Program) -> Result<ProgramResult> { |
| 716 | let mut steps = Vec::with_capacity(program.steps.len()); |
| 717 | let mut success = true; |
| 718 | |
| 719 | for step in &program.steps { |
| 720 | let result = self |
| 721 | .registry |
| 722 | .execute_with_context(&step.tool_name, &step.args, &self.context) |
| 723 | .await?; |
| 724 | |
| 725 | let step_success = result.exit_code == 0; |
| 726 | success &= step_success; |
| 727 | steps.push(ProgramStepResult { |
| 728 | tool_name: step.tool_name.clone(), |
| 729 | label: step.label.clone(), |
| 730 | success: step_success, |
| 731 | output: result.output, |
| 732 | metadata: result.metadata, |
| 733 | }); |
| 734 | |
| 735 | if !step_success { |
| 736 | break; |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | Ok(ProgramResult { |
| 741 | program_name: program.name.clone(), |
| 742 | success, |
| 743 | summary: summarize_program_result(program, success, steps.len()), |
| 744 | steps, |
| 745 | }) |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | pub fn builtin_program_templates() -> Vec<ProgramTemplate> { |