Refactor IPC and DTO structures; remove unused code and streamline message handling

- Removed unused structs and methods from `response.rs`, `usage.rs`, and `client.rs`.
- Simplified `Connection` handling in `conn.rs` to only support Unix sockets.
- Updated `IpcServer` to exclusively use Unix sockets and removed TCP handling.
- Cleaned up `editlog.rs` by removing loading and recent entry methods.
- Refactored `memory.rs` to eliminate unused functions related to lesson promotion and retrospective creation.
- Enhanced `search.rs` to support multiple search providers and improved error handling.
- Updated chat view logic to simplify message display and improve user experience.
- Removed deprecated modules and constants from various files to streamline the codebase.
This commit is contained in:
asepharyana
2026-07-11 23:45:13 +07:00
parent 93d1bbb7c1
commit fcef85a327
51 changed files with 1431 additions and 1246 deletions
-4
View File
@@ -4,12 +4,10 @@ use super::spawn::AgentDefinition;
pub const REVIEWER_ALLOWED: &[&str] = &["read", "grep", "glob", "recall", "remember"];
pub struct SubagentContext {
pub definition: AgentDefinition,
pub system_prompt: String,
pub allowed_tools: Vec<String>,
pub max_steps: usize,
pub session_dir: PathBuf,
pub origin: crate::app::state::types::Origin,
}
pub fn build_subagent_context(def: AgentDefinition) -> SubagentContext {
@@ -21,11 +19,9 @@ pub fn build_subagent_context(def: AgentDefinition) -> SubagentContext {
}
});
SubagentContext {
definition: def,
system_prompt: String::new(),
allowed_tools,
max_steps: 25,
session_dir: PathBuf::new(),
origin: crate::app::state::types::Origin::SubAgent,
}
}
+17 -17
View File
@@ -37,16 +37,16 @@ pub fn run_subagent(ctx: SubagentContext, tx: mpsc::Sender<SubagentEvent>) -> an
Ok(r) => r,
Err(e) => {
let _ = tx.blocking_send(SubagentEvent::StepFailed {
step,
error: e.to_string(),
_step: step,
_error: e.to_string(),
});
anyhow::bail!("subagent call failed at step {}: {}", step, e);
}
};
let _ = tx.blocking_send(SubagentEvent::ToolCall {
tool: "api".to_string(),
args: serde_json::json!({"response": response}),
_tool: "api".to_string(),
_args: serde_json::json!({"response": response}),
});
let tool_calls = tool_call_from_response(&response);
@@ -54,8 +54,8 @@ pub fn run_subagent(ctx: SubagentContext, tx: mpsc::Sender<SubagentEvent>) -> an
output.push_str(&response);
output.push('\n');
let _ = tx.blocking_send(SubagentEvent::StepCompleted {
step,
output: response.clone(),
_step: step,
_output: response.clone(),
});
if !response.contains("Tool:") {
break;
@@ -70,8 +70,8 @@ pub fn run_subagent(ctx: SubagentContext, tx: mpsc::Sender<SubagentEvent>) -> an
let msg = format!("tool '{}' not allowed for this subagent", tool_name);
messages.push(ChatMessage::tool_result(tool_name.clone(), msg.clone()));
let _ = tx.blocking_send(SubagentEvent::ToolResult {
tool: tool_name.clone(),
output: msg,
_tool: tool_name.clone(),
_output: msg,
});
continue;
}
@@ -80,8 +80,8 @@ pub fn run_subagent(ctx: SubagentContext, tx: mpsc::Sender<SubagentEvent>) -> an
let msg = format!("risky tool '{}' requires explicit permission; not allowed for this subagent", tool_name);
messages.push(ChatMessage::tool_result(tool_name.clone(), msg.clone()));
let _ = tx.blocking_send(SubagentEvent::ToolResult {
tool: tool_name.clone(),
output: msg,
_tool: tool_name.clone(),
_output: msg,
});
continue;
}
@@ -94,22 +94,22 @@ pub fn run_subagent(ctx: SubagentContext, tx: mpsc::Sender<SubagentEvent>) -> an
match result {
Ok(output_text) => {
let _ = tx.blocking_send(SubagentEvent::ToolResult {
tool: tool_name.clone(),
output: output_text,
_tool: tool_name.clone(),
_output: output_text,
});
}
Err(e) => {
let msg = format!("tool '{}' failed: {}", tool_name, e);
let _ = tx.blocking_send(SubagentEvent::ToolResult {
tool: tool_name.clone(),
output: msg,
_tool: tool_name.clone(),
_output: msg,
});
}
}
}
let _ = tx.blocking_send(SubagentEvent::StepCompleted {
step,
output: response.clone(),
_step: step,
_output: response.clone(),
});
}
@@ -119,6 +119,6 @@ pub fn run_subagent(ctx: SubagentContext, tx: mpsc::Sender<SubagentEvent>) -> an
messages.push(user_msg);
}
let _ = tx.blocking_send(SubagentEvent::Completed { output: output.clone() });
let _ = tx.blocking_send(SubagentEvent::Completed { _output: output.clone() });
Ok(output)
}
+9 -12
View File
@@ -3,25 +3,22 @@ use serde_json::Value;
#[derive(Debug, Clone)]
pub enum SubagentEvent {
StepCompleted {
step: usize,
output: String,
_step: usize,
_output: String,
},
StepFailed {
step: usize,
error: String,
_step: usize,
_error: String,
},
Completed {
output: String,
},
Failed {
error: String,
_output: String,
},
ToolCall {
tool: String,
args: Value,
_tool: String,
_args: Value,
},
ToolResult {
tool: String,
output: String,
_tool: String,
_output: String,
},
}
-26
View File
@@ -22,34 +22,8 @@ impl AgentDefinition {
}
}
pub fn with_system_prompt(mut self, prompt: String) -> Self {
self.system_prompt = Some(prompt);
self
}
pub fn with_allowed_tools(mut self, tools: Vec<String>) -> Self {
self.allowed_tools = Some(tools);
self
}
pub fn with_max_steps(mut self, steps: usize) -> Self {
self.max_steps = Some(steps);
self
}
pub fn with_temperature(mut self, temp: f32) -> Self {
self.temperature = Some(temp);
self
}
}
pub fn merge_agent_defs(base: AgentDefinition, overrides: AgentDefinition) -> AgentDefinition {
AgentDefinition {
name: base.name,
role: base.role,
system_prompt: overrides.system_prompt.or(base.system_prompt),
allowed_tools: overrides.allowed_tools.or(base.allowed_tools),
max_steps: overrides.max_steps.or(base.max_steps),
temperature: overrides.temperature.or(base.temperature),
}
}