修复消息渠道的事件未触发
This commit is contained in:
@@ -288,6 +288,7 @@ pub async fn spawn_agent_connection(
|
||||
AcpEvent::Error {
|
||||
connection_id: conn_id.clone(),
|
||||
message: e.to_string(),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -829,6 +830,7 @@ async fn run_connection(
|
||||
message: format!(
|
||||
"Failed to load session, starting new: {e}"
|
||||
),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1578,6 +1580,7 @@ async fn run_conversation_loop<'a>(
|
||||
AcpEvent::Error {
|
||||
connection_id: conn_id.into(),
|
||||
message: "Prompt must contain at least one content block".into(),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
continue;
|
||||
@@ -1684,6 +1687,7 @@ async fn run_conversation_loop<'a>(
|
||||
connection_id: conn_id.into(),
|
||||
session_id: sid.0.to_string(),
|
||||
stop_reason: reason_str.into(),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
break;
|
||||
@@ -1715,6 +1719,7 @@ async fn run_conversation_loop<'a>(
|
||||
connection_id: conn_id.into(),
|
||||
session_id: sid.0.to_string(),
|
||||
stop_reason: reason_str.into(),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
break;
|
||||
@@ -1762,6 +1767,7 @@ async fn run_conversation_loop<'a>(
|
||||
AcpEvent::Error {
|
||||
connection_id: conn_id.into(),
|
||||
message: format!("Failed to set mode: {e}"),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1788,6 +1794,7 @@ async fn run_conversation_loop<'a>(
|
||||
AcpEvent::Error {
|
||||
connection_id: conn_id.into(),
|
||||
message: format!("Failed to set config option: {e}"),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1823,6 +1830,7 @@ async fn run_conversation_loop<'a>(
|
||||
connection_id: conn_id.into(),
|
||||
session_id: sid.0.to_string(),
|
||||
stop_reason: "cancelled".into(),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
// Drain the prompt response in the background so
|
||||
@@ -1895,6 +1903,7 @@ async fn run_conversation_loop<'a>(
|
||||
AcpEvent::Error {
|
||||
connection_id: conn_id.into(),
|
||||
message: format!("Failed to set mode: {e}"),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1914,6 +1923,7 @@ async fn run_conversation_loop<'a>(
|
||||
AcpEvent::Error {
|
||||
connection_id: conn_id.into(),
|
||||
message: format!("Failed to set config option: {e}"),
|
||||
agent_type: agent_type.to_string(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ pub enum AcpEvent {
|
||||
connection_id: String,
|
||||
session_id: String,
|
||||
stop_reason: String,
|
||||
agent_type: String,
|
||||
},
|
||||
/// Session established with agent-assigned session ID
|
||||
SessionStarted {
|
||||
@@ -129,6 +130,7 @@ pub enum AcpEvent {
|
||||
Error {
|
||||
connection_id: String,
|
||||
message: String,
|
||||
agent_type: String,
|
||||
},
|
||||
/// Available slash commands updated
|
||||
AvailableCommands {
|
||||
|
||||
@@ -126,7 +126,7 @@ fn parse_acp_event(payload: &serde_json::Value, lang: Lang) -> Option<(String, R
|
||||
match event_type {
|
||||
"turn_complete" => {
|
||||
let stop_reason = payload
|
||||
.pointer("/data/stop_reason")
|
||||
.get("stop_reason")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("unknown");
|
||||
// Only push for end_turn, not for intermediate completions
|
||||
@@ -134,7 +134,7 @@ fn parse_acp_event(payload: &serde_json::Value, lang: Lang) -> Option<(String, R
|
||||
return None;
|
||||
}
|
||||
let agent_type = payload
|
||||
.pointer("/data/agent_type")
|
||||
.get("agent_type")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("Unknown Agent");
|
||||
Some((
|
||||
@@ -144,11 +144,11 @@ fn parse_acp_event(payload: &serde_json::Value, lang: Lang) -> Option<(String, R
|
||||
}
|
||||
"error" => {
|
||||
let agent_type = payload
|
||||
.pointer("/data/agent_type")
|
||||
.get("agent_type")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("Unknown Agent");
|
||||
let message = payload
|
||||
.pointer("/data/message")
|
||||
.get("message")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("Unknown error");
|
||||
Some((
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum Lang {
|
||||
#[default]
|
||||
En,
|
||||
ZhCn,
|
||||
ZhTw,
|
||||
@@ -15,12 +16,6 @@ pub enum Lang {
|
||||
Ar,
|
||||
}
|
||||
|
||||
impl Default for Lang {
|
||||
fn default() -> Self {
|
||||
Lang::En
|
||||
}
|
||||
}
|
||||
|
||||
impl Lang {
|
||||
pub fn from_str_lossy(s: &str) -> Self {
|
||||
match s {
|
||||
|
||||
Reference in New Issue
Block a user