Refactor CMS and IAM modules: restructure presentation and command layers
- Removed HTTP adapter module from CMS infrastructure. - Updated CMS infrastructure module to exclude HTTP. - Introduced presentation layer in CMS with DTOs and handlers for REST API. - Added command types for CMS domain operations to encapsulate input data. - Created typed error handling for CMS presentation layer. - Implemented handlers for CMS REST API endpoints. - Removed HTTP DTOs and handlers from IAM infrastructure. - Introduced command types for IAM domain operations. - Created presentation layer in IAM with DTOs and handlers for OAuth flow. - Implemented typed error handling for IAM presentation layer.
This commit is contained in:
@@ -139,7 +139,7 @@ pub(super) fn run_agent_turn(
|
||||
"[hive-mind] the Hive stirs — Core Intelligence compiling a cognitive cycle plan"
|
||||
);
|
||||
|
||||
push_event(&events_q, TurnEvent::SystemNote {
|
||||
push_event(events_q, TurnEvent::SystemNote {
|
||||
kind: "pipeline".to_string(),
|
||||
message: HIVE_MIND_KICKOFF_NOTE.to_string(),
|
||||
});
|
||||
@@ -206,7 +206,7 @@ pub(super) fn run_agent_turn(
|
||||
let response_chars = reply.content.as_deref().map_or(0, str::len);
|
||||
tok_out = ((response_chars / 4).max(1)).cast_or(1u64);
|
||||
}
|
||||
push_event(&events_q, TurnEvent::Usage {
|
||||
push_event(events_q, TurnEvent::Usage {
|
||||
tokens_in: tok_in,
|
||||
tokens_out: tok_out,
|
||||
});
|
||||
@@ -236,7 +236,7 @@ pub(super) fn run_agent_turn(
|
||||
.collect::<Vec<String>>()
|
||||
.join(", ");
|
||||
|
||||
push_event(&events_q, TurnEvent::SystemNote {
|
||||
push_event(events_q, TurnEvent::SystemNote {
|
||||
kind: "pipeline".to_string(),
|
||||
message: format!(
|
||||
"The Hive compiled {} cycle(s) — {cycle_desc}. Deploying nodes...",
|
||||
@@ -279,13 +279,13 @@ pub(super) fn run_agent_turn(
|
||||
archive_message(tc.db.as_ref(), &tc.session_id, &pipeline_msg);
|
||||
msgs.push(pipeline_msg);
|
||||
|
||||
push_event(&events_q, TurnEvent::SystemNote {
|
||||
push_event(events_q, TurnEvent::SystemNote {
|
||||
kind: "pipeline".to_string(),
|
||||
message:
|
||||
"The Hive's convergence is complete. Core Intelligence reviewing consensus for LO..."
|
||||
.to_string(),
|
||||
});
|
||||
push_event(&events_q, TurnEvent::SystemNote {
|
||||
push_event(events_q, TurnEvent::SystemNote {
|
||||
kind: "hive_mind_converged".to_string(),
|
||||
message: String::new(),
|
||||
});
|
||||
@@ -308,7 +308,7 @@ pub(super) fn run_agent_turn(
|
||||
// phase, which previously ran unchecked for minutes at a time.
|
||||
if crate::app::util::abort::is_aborted_direct(&tc.abort_flag)
|
||||
{
|
||||
push_event(&events_q, TurnEvent::Error("Generation aborted by user".to_string()));
|
||||
push_event(events_q, TurnEvent::Error("Generation aborted by user".to_string()));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ pub(super) fn run_agent_turn(
|
||||
|
||||
// Dispatch the compacted messages to the main thread so the local session history
|
||||
// is permanently compacted and doesn't trigger shaping again immediately on next turn.
|
||||
push_event(&events_q, TurnEvent::Compacted(compacted.clone()));
|
||||
push_event(events_q, TurnEvent::Compacted(compacted.clone()));
|
||||
|
||||
// Also update our local `msgs` variable so the rest of the loop operates on the compacted version
|
||||
msgs.clone_from(&compacted);
|
||||
@@ -417,7 +417,7 @@ pub(super) fn run_agent_turn(
|
||||
);
|
||||
|
||||
if reasoning_started && !reasoning_ended {
|
||||
push_event(&events_q, TurnEvent::StreamToken(
|
||||
push_event(events_q, TurnEvent::StreamToken(
|
||||
"\n</think>\n\n".to_string(),
|
||||
));
|
||||
}
|
||||
@@ -429,7 +429,7 @@ pub(super) fn run_agent_turn(
|
||||
if crate::app::util::abort::is_aborted_direct(&tc.abort_flag)
|
||||
|| e.to_string().contains("aborted")
|
||||
{
|
||||
push_event(&events_q, TurnEvent::Error(
|
||||
push_event(events_q, TurnEvent::Error(
|
||||
"Generation aborted by user".to_string(),
|
||||
));
|
||||
return Ok(());
|
||||
@@ -458,7 +458,7 @@ pub(super) fn run_agent_turn(
|
||||
Edit todo.md manually or ask me to focus on specific items.",
|
||||
);
|
||||
}
|
||||
push_event(&events_q, TurnEvent::SystemNote {
|
||||
push_event(events_q, TurnEvent::SystemNote {
|
||||
kind: "task_retry".to_string(),
|
||||
message: format!(
|
||||
"Network/API error: {api_err}. Auto-retrying to finish tasks... (retry {todo_retry_count}/{MAX_TODO_RETRIES})"
|
||||
@@ -484,7 +484,7 @@ pub(super) fn run_agent_turn(
|
||||
let response_chars = response.content.as_deref().map_or(0, str::len);
|
||||
tok_out = ((response_chars / 4).max(1)).cast_or(1u64);
|
||||
}
|
||||
push_event(&events_q, TurnEvent::Usage {
|
||||
push_event(events_q, TurnEvent::Usage {
|
||||
tokens_in: tok_in,
|
||||
tokens_out: tok_out,
|
||||
});
|
||||
@@ -558,7 +558,7 @@ pub(super) fn run_agent_turn(
|
||||
for (tool_call, tool_name, args, output, is_error, is_edit) in results_vec {
|
||||
if crate::app::util::abort::is_aborted_direct(&tc.abort_flag)
|
||||
{
|
||||
push_event(&events_q, TurnEvent::Error(
|
||||
push_event(events_q, TurnEvent::Error(
|
||||
"Turn aborted by user".to_string(),
|
||||
));
|
||||
return Ok(());
|
||||
@@ -629,7 +629,7 @@ pub(super) fn run_agent_turn(
|
||||
.and_then(|v| v.as_str())
|
||||
.map(std::string::ToString::to_string);
|
||||
|
||||
push_event(&events_q, TurnEvent::ToolResult {
|
||||
push_event(events_q, TurnEvent::ToolResult {
|
||||
tool_call_id: tool_call.id.clone(),
|
||||
tool_name: tool_name.clone(),
|
||||
output: output.clone(),
|
||||
@@ -646,9 +646,9 @@ pub(super) fn run_agent_turn(
|
||||
if !content.is_empty() {
|
||||
archive_message(tc.db.as_ref(), &tc.session_id, &response);
|
||||
if stream_started {
|
||||
push_event(&events_q, TurnEvent::StreamDone(response.clone()));
|
||||
push_event(events_q, TurnEvent::StreamDone(response.clone()));
|
||||
} else {
|
||||
push_event(&events_q, TurnEvent::AssistantMessage(response.clone()));
|
||||
push_event(events_q, TurnEvent::AssistantMessage(response.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,7 +666,7 @@ pub(super) fn run_agent_turn(
|
||||
if has_unfinished {
|
||||
todo_retry_count += 1;
|
||||
if todo_retry_count > MAX_TODO_RETRIES {
|
||||
push_event(&events_q, TurnEvent::SystemNote {
|
||||
push_event(events_q, TurnEvent::SystemNote {
|
||||
kind: "task_retry".to_string(),
|
||||
message: format!("Giving up after {MAX_TODO_RETRIES} retries — some todo items remain unfinished. Edit todo.md manually or ask again."),
|
||||
});
|
||||
@@ -677,7 +677,7 @@ pub(super) fn run_agent_turn(
|
||||
let msg = ChatMessage::system(sys_text);
|
||||
archive_message(tc.db.as_ref(), &tc.session_id, &msg);
|
||||
msgs.push(msg);
|
||||
push_event(&events_q, TurnEvent::SystemNote {
|
||||
push_event(events_q, TurnEvent::SystemNote {
|
||||
kind: "task_retry".to_string(),
|
||||
message: sys_text_clone,
|
||||
});
|
||||
@@ -701,7 +701,7 @@ pub(super) fn run_agent_turn(
|
||||
|
||||
if let Some((total_edits_this_turn, prev_edits, el)) = &total_edits_this_turn {
|
||||
if *total_edits_this_turn > 0 {
|
||||
push_event(&events_q, TurnEvent::SystemNote {
|
||||
push_event(events_q, TurnEvent::SystemNote {
|
||||
kind: "edits".to_string(),
|
||||
message: total_edits_this_turn.to_string(),
|
||||
});
|
||||
@@ -738,7 +738,7 @@ pub(super) fn run_agent_turn(
|
||||
total_edits_this_turn.as_ref().map_or(0, |(c, _, _)| *c),
|
||||
);
|
||||
|
||||
push_event(&events_q, TurnEvent::Done);
|
||||
push_event(events_q, TurnEvent::Done);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user