summaryrefslogtreecommitdiff
path: root/makima/src/daemon
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-20 12:47:39 +0000
committersoryu <soryu@soryu.co>2026-01-20 12:56:58 +0000
commit36233b7cb834223878aa075bb379846eb6d7bb05 (patch)
treed3eec4bc5fd30d41afe2d9df82ac62ca3f405a65 /makima/src/daemon
parent7d5af3d817cf8aa62c9ee12b7f78a17730182e1d (diff)
downloadsoryu-36233b7cb834223878aa075bb379846eb6d7bb05.tar.gz
soryu-36233b7cb834223878aa075bb379846eb6d7bb05.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/daemon')
-rw-r--r--makima/src/daemon/api/supervisor.rs35
-rw-r--r--makima/src/daemon/cli/mod.rs6
-rw-r--r--makima/src/daemon/cli/supervisor.rs27
-rw-r--r--makima/src/daemon/task/manager.rs3
4 files changed, 71 insertions, 0 deletions
diff --git a/makima/src/daemon/api/supervisor.rs b/makima/src/daemon/api/supervisor.rs
index 1dc699e..26d786c 100644
--- a/makima/src/daemon/api/supervisor.rs
+++ b/makima/src/daemon/api/supervisor.rs
@@ -248,4 +248,39 @@ impl ApiClient {
self.get(&format!("/api/v1/mesh/tasks/{}/output", task_id))
.await
}
+
+ /// Mark a contract as complete.
+ /// This will update contract status to 'completed', stop the supervisor, and clean up worktrees.
+ pub async fn supervisor_complete(&self, contract_id: Uuid) -> Result<JsonValue, ApiError> {
+ #[derive(Serialize)]
+ #[serde(rename_all = "camelCase")]
+ struct CompleteContractRequest {
+ status: String,
+ }
+ let req = CompleteContractRequest {
+ status: "completed".to_string(),
+ };
+ self.put(&format!("/api/v1/contracts/{}", contract_id), &req)
+ .await
+ }
+
+ /// Resume a completed contract (reactivate it).
+ ///
+ /// This updates the contract status from 'completed' back to 'active'
+ /// and optionally respawns the supervisor task.
+ pub async fn supervisor_resume_contract(
+ &self,
+ contract_id: Uuid,
+ ) -> Result<JsonValue, ApiError> {
+ #[derive(Serialize)]
+ #[serde(rename_all = "camelCase")]
+ struct ResumeContractRequest {
+ status: String,
+ }
+ let req = ResumeContractRequest {
+ status: "active".to_string(),
+ };
+ self.put(&format!("/api/v1/contracts/{}", contract_id), &req)
+ .await
+ }
}
diff --git a/makima/src/daemon/cli/mod.rs b/makima/src/daemon/cli/mod.rs
index 842fa63..44c7a06 100644
--- a/makima/src/daemon/cli/mod.rs
+++ b/makima/src/daemon/cli/mod.rs
@@ -122,6 +122,12 @@ pub enum SupervisorCommand {
/// Rewind supervisor conversation
RewindConversation(supervisor::ConversationRewindArgs),
+
+ /// Mark the contract as complete and stop the supervisor
+ Complete(supervisor::CompleteArgs),
+
+ /// Resume a completed contract (reactivate it)
+ ResumeContract(supervisor::ResumeContractArgs),
}
/// Contract subcommands for task-contract interaction.
diff --git a/makima/src/daemon/cli/supervisor.rs b/makima/src/daemon/cli/supervisor.rs
index ae1a126..798a55f 100644
--- a/makima/src/daemon/cli/supervisor.rs
+++ b/makima/src/daemon/cli/supervisor.rs
@@ -390,3 +390,30 @@ pub struct ConversationRewindArgs {
#[arg(long)]
pub rewind_code: bool,
}
+
+/// Arguments for complete command (mark contract as complete).
+#[derive(Args, Debug)]
+pub struct CompleteArgs {
+ #[command(flatten)]
+ pub common: SupervisorArgs,
+}
+
+// ============================================================================
+// Resume Contract Command Args
+// ============================================================================
+
+/// Arguments for resume-contract command (reactivate a completed contract).
+#[derive(Args, Debug)]
+pub struct ResumeContractArgs {
+ /// API URL
+ #[arg(long, env = "MAKIMA_API_URL", default_value = "https://api.makima.jp")]
+ pub api_url: String,
+
+ /// API key for authentication
+ #[arg(long, env = "MAKIMA_API_KEY")]
+ pub api_key: String,
+
+ /// Contract ID to resume
+ #[arg(index = 1)]
+ pub contract_id: Uuid,
+}
diff --git a/makima/src/daemon/task/manager.rs b/makima/src/daemon/task/manager.rs
index 80b7039..555cd2a 100644
--- a/makima/src/daemon/task/manager.rs
+++ b/makima/src/daemon/task/manager.rs
@@ -980,6 +980,8 @@ pub struct TaskConfig {
pub bubblewrap: Option<crate::daemon::config::BubblewrapConfig>,
/// API URL for spawned tasks (HTTP endpoint for makima CLI).
pub api_url: String,
+ /// API key for making authenticated API calls.
+ pub api_key: String,
/// Interval in seconds between heartbeat commits (WIP checkpoints).
/// Set to 0 to disable. Default: 300 (5 minutes).
pub heartbeat_commit_interval_secs: u64,
@@ -998,6 +1000,7 @@ impl Default for TaskConfig {
disable_verbose: false,
bubblewrap: None,
api_url: "https://api.makima.jp".to_string(),
+ api_key: String::new(),
heartbeat_commit_interval_secs: 300, // 5 minutes
}
}