From 54c6d409e1d5667f4ab7f63a43e1459e68575c94 Mon Sep 17 00:00:00 2001 From: soryu Date: Tue, 20 Jan 2026 17:19:18 +0000 Subject: Clean contract lifecycle: Add supervisor complete command (#13) * feat: Add contract lifecycle management commands (complete and resume-contract) Add supervisor commands for properly managing contract lifecycle: - `makima supervisor complete` - Mark a contract as complete and stop the supervisor - `makima supervisor resume-contract` - Resume a completed contract (reactivate it) Also adds `api_key` field to TaskConfig for authenticated API calls. This consolidates the lifecycle management features from the contract-lifecycle-cleanup branch. Co-Authored-By: Claude Opus 4.5 * Fix: prevent supervisor auto-start for completed contracts When viewing a completed contract, the supervisor was auto-starting on component mount. This would resurrect completed contracts and cause them to continue running. Changes: - Add contract.status !== 'completed' check to the auto-start condition - Add contract.status to the useEffect dependency array Co-Authored-By: Claude Opus 4.5 * Task completion checkpoint --------- Co-authored-by: Claude Opus 4.5 --- makima/src/bin/makima.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'makima/src/bin') diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs index 972e575..8b3e4dc 100644 --- a/makima/src/bin/makima.rs +++ b/makima/src/bin/makima.rs @@ -187,6 +187,7 @@ async fn run_daemon( disable_verbose: config.process.disable_verbose, bubblewrap: bubblewrap_config, api_url, + api_key: config.server.api_key.clone(), heartbeat_commit_interval_secs: config.process.heartbeat_commit_interval_secs, }; @@ -439,6 +440,30 @@ async fn run_supervisor( args.common.contract_id ); } + SupervisorCommand::Complete(args) => { + let client = ApiClient::new(args.common.api_url, args.common.api_key)?; + eprintln!("Marking contract {} as complete...", args.common.contract_id); + match client.supervisor_complete(args.common.contract_id).await { + Ok(_) => { + println!(r#"{{"success": true, "message": "Contract marked as complete"}}"#); + } + Err(e) => { + eprintln!("Error: {}", e); + println!(r#"{{"success": false, "error": "{}"}}"#, e); + std::process::exit(1); + } + } + } + SupervisorCommand::ResumeContract(args) => { + let client = ApiClient::new(args.api_url, args.api_key)?; + eprintln!("Resuming contract {}...", args.contract_id); + let result = client.supervisor_resume_contract(args.contract_id).await?; + println!("{}", serde_json::to_string(&serde_json::json!({ + "success": true, + "message": "Contract resumed", + "contract": result.0 + }))?); + } } Ok(()) -- cgit v1.2.3