summaryrefslogtreecommitdiff
path: root/makima/src
diff options
context:
space:
mode:
Diffstat (limited to 'makima/src')
-rw-r--r--makima/src/bin/makima.rs2
-rw-r--r--makima/src/daemon/api/supervisor.rs10
-rw-r--r--makima/src/daemon/cli/supervisor.rs8
-rw-r--r--makima/src/server/handlers/mesh_supervisor.rs28
-rw-r--r--makima/src/server/state.rs5
5 files changed, 52 insertions, 1 deletions
diff --git a/makima/src/bin/makima.rs b/makima/src/bin/makima.rs
index 972e575..ba74f96 100644
--- a/makima/src/bin/makima.rs
+++ b/makima/src/bin/makima.rs
@@ -352,7 +352,7 @@ async fn run_supervisor(
.map(|c| c.split(',').map(|s| s.trim().to_string()).collect())
.unwrap_or_default();
let result = client
- .supervisor_ask(&args.question, choices, args.context, args.timeout, args.phaseguard, args.multi_select)
+ .supervisor_ask(&args.question, choices, args.context, args.timeout, args.phaseguard, args.multi_select, args.non_blocking, args.question_type)
.await?;
println!("{}", serde_json::to_string(&result.0)?);
}
diff --git a/makima/src/daemon/api/supervisor.rs b/makima/src/daemon/api/supervisor.rs
index 9614cfc..f9d2c5b 100644
--- a/makima/src/daemon/api/supervisor.rs
+++ b/makima/src/daemon/api/supervisor.rs
@@ -76,6 +76,12 @@ pub struct AskQuestionRequest {
/// When true, allow selecting multiple choices (response will be comma-separated)
#[serde(default)]
pub multi_select: bool,
+ /// When true, return immediately without waiting for response
+ #[serde(default)]
+ pub non_blocking: bool,
+ /// Question type: general, phase_confirmation, or contract_complete
+ #[serde(default)]
+ pub question_type: String,
}
// Generic response type for JSON output
@@ -209,6 +215,8 @@ impl ApiClient {
timeout_seconds: i32,
phaseguard: bool,
multi_select: bool,
+ non_blocking: bool,
+ question_type: String,
) -> Result<JsonValue, ApiError> {
let req = AskQuestionRequest {
question: question.to_string(),
@@ -217,6 +225,8 @@ impl ApiClient {
timeout_seconds,
phaseguard,
multi_select,
+ non_blocking,
+ question_type,
};
self.post("/api/v1/mesh/supervisor/questions", &req).await
}
diff --git a/makima/src/daemon/cli/supervisor.rs b/makima/src/daemon/cli/supervisor.rs
index ae1a126..e53af5b 100644
--- a/makima/src/daemon/cli/supervisor.rs
+++ b/makima/src/daemon/cli/supervisor.rs
@@ -188,6 +188,14 @@ pub struct AskArgs {
/// Allow selecting multiple choices (response will be comma-separated)
#[arg(long, default_value = "false")]
pub multi_select: bool,
+
+ /// Non-blocking mode - returns immediately without waiting for response
+ #[arg(long, default_value = "false")]
+ pub non_blocking: bool,
+
+ /// Question type (general, phase_confirmation, contract_complete)
+ #[arg(long, default_value = "general")]
+ pub question_type: String,
}
/// Arguments for status command (get contract status including phase).
diff --git a/makima/src/server/handlers/mesh_supervisor.rs b/makima/src/server/handlers/mesh_supervisor.rs
index df8f77c..e5d33c7 100644
--- a/makima/src/server/handlers/mesh_supervisor.rs
+++ b/makima/src/server/handlers/mesh_supervisor.rs
@@ -76,6 +76,16 @@ pub struct AskQuestionRequest {
/// When true, allow selecting multiple choices (response will be comma-separated)
#[serde(default)]
pub multi_select: bool,
+ /// When true, return immediately without waiting for response
+ #[serde(default)]
+ pub non_blocking: bool,
+ /// Question type: general, phase_confirmation, or contract_complete
+ #[serde(default = "default_question_type")]
+ pub question_type: String,
+}
+
+fn default_question_type() -> String {
+ "general".to_string()
}
fn default_question_timeout() -> i32 {
@@ -124,6 +134,9 @@ pub struct PendingQuestionSummary {
/// Whether multiple choices can be selected
#[serde(default)]
pub multi_select: bool,
+ /// Question type: general, phase_confirmation, or contract_complete
+ #[serde(default)]
+ pub question_type: String,
}
/// Request to create a checkpoint.
@@ -1532,6 +1545,7 @@ pub async fn ask_question(
request.choices.clone(),
request.context.clone(),
request.multi_select,
+ request.question_type.clone(),
);
// Broadcast question as task output entry for the task's chat
@@ -1540,6 +1554,7 @@ pub async fn ask_question(
"choices": request.choices,
"context": request.context,
"multi_select": request.multi_select,
+ "question_type": request.question_type,
});
state.broadcast_task_output(TaskOutputNotification {
task_id: supervisor_id,
@@ -1572,6 +1587,18 @@ pub async fn ask_question(
).await;
}
+ // If non_blocking mode is enabled, return immediately with the question_id
+ if request.non_blocking {
+ return (
+ StatusCode::OK,
+ Json(AskQuestionResponse {
+ question_id,
+ response: None,
+ timed_out: false,
+ }),
+ ).into_response();
+ }
+
// Poll for response with timeout
let timeout_duration = std::time::Duration::from_secs(request.timeout_seconds.max(1) as u64);
let start = std::time::Instant::now();
@@ -1644,6 +1671,7 @@ pub async fn list_pending_questions(
context: q.context,
created_at: q.created_at,
multi_select: q.multi_select,
+ question_type: q.question_type,
})
.collect();
diff --git a/makima/src/server/state.rs b/makima/src/server/state.rs
index c5736af..38aadf5 100644
--- a/makima/src/server/state.rs
+++ b/makima/src/server/state.rs
@@ -146,6 +146,8 @@ pub struct PendingSupervisorQuestion {
pub created_at: chrono::DateTime<chrono::Utc>,
/// Whether multiple choices can be selected
pub multi_select: bool,
+ /// Question type: general, phase_confirmation, or contract_complete
+ pub question_type: String,
}
/// Response to a supervisor question
@@ -666,6 +668,7 @@ impl AppState {
choices: Vec<String>,
context: Option<String>,
multi_select: bool,
+ question_type: String,
) -> Uuid {
let question_id = Uuid::new_v4();
let now = chrono::Utc::now();
@@ -683,6 +686,7 @@ impl AppState {
context: context.clone(),
created_at: now,
multi_select,
+ question_type: question_type.clone(),
},
);
@@ -704,6 +708,7 @@ impl AppState {
question_id = %question_id,
task_id = %task_id,
contract_id = %contract_id,
+ question_type = %question_type,
"Supervisor question added"
);