chore: fix formatting and clippy lints
This commit is contained in:
1 parent
8952bd5399
commit
9d9e959744
35 files changed
+1091
-582
No files matched your search
+97
-29
@@ -639,12 +639,19 @@ impl MemoryHandler {
|
||||
if let Some(resource) = self.resources.get(uri) {
|
||||
match resource.read(Arc::clone(&self.state)).await {
|
||||
Ok(text) => {
|
||||
let mut content_obj = serde_json::json!({
|
||||
"uri": uri,
|
||||
"mimeType": resource.mime_type().unwrap_or("application/json"),
|
||||
"text": &text
|
||||
});
|
||||
|
||||
if text.len() > 4000 {
|
||||
content_obj["cacheControl"] =
|
||||
serde_json::json!({"type": "ephemeral"});
|
||||
}
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"contents": [{
|
||||
"uri": uri,
|
||||
"mimeType": resource.mime_type().unwrap_or("application/json"),
|
||||
"text": text
|
||||
}]
|
||||
"contents": [content_obj]
|
||||
});
|
||||
Some(crate::mcp::success(id, payload))
|
||||
}
|
||||
@@ -756,8 +763,15 @@ impl MemoryHandler {
|
||||
|
||||
match result {
|
||||
Ok(text) => {
|
||||
let mut content_obj = serde_json::json!({"type": "text", "text": &text});
|
||||
|
||||
// Heuristic: If response is large (e.g. > 4000 chars), inject cache_control for Prompt Caching
|
||||
if text.len() > 4000 {
|
||||
content_obj["cacheControl"] = serde_json::json!({"type": "ephemeral"});
|
||||
}
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"content": [{"type": "text", "text": text}],
|
||||
"content": [content_obj],
|
||||
"isError": false
|
||||
});
|
||||
Some(crate::mcp::success(id_clone, payload))
|
||||
@@ -788,8 +802,13 @@ impl MemoryHandler {
|
||||
}
|
||||
});
|
||||
let unblocked = crate::handlers::reconciliation::cascade_unblock_tasks(&self.state);
|
||||
let milestones = crate::handlers::reconciliation::recalculate_milestones(&self.state);
|
||||
self.state.record_activity("task", &format!("Completed task via WebSocket RPC: {}", task_id), Some("completed"));
|
||||
let milestones =
|
||||
crate::handlers::reconciliation::recalculate_milestones(&self.state);
|
||||
self.state.record_activity(
|
||||
"task",
|
||||
&format!("Completed task via WebSocket RPC: {}", task_id),
|
||||
Some("completed"),
|
||||
);
|
||||
let _ = self.state.event_bus_tx.send(crate::state::GenericEvent {
|
||||
topic: "task:event".to_string(),
|
||||
session_id: None,
|
||||
@@ -800,11 +819,14 @@ impl MemoryHandler {
|
||||
"updated_milestones": milestones,
|
||||
}),
|
||||
});
|
||||
Some(crate::mcp::success(id, serde_json::json!({
|
||||
"status": "success",
|
||||
"unblocked_tasks": unblocked,
|
||||
"updated_milestones": milestones
|
||||
})))
|
||||
Some(crate::mcp::success(
|
||||
id,
|
||||
serde_json::json!({
|
||||
"status": "success",
|
||||
"unblocked_tasks": unblocked,
|
||||
"updated_milestones": milestones
|
||||
}),
|
||||
))
|
||||
}
|
||||
"tech_debts/resolve" => {
|
||||
let params = req.get("params").unwrap_or(&serde_json::Value::Null);
|
||||
@@ -823,7 +845,11 @@ impl MemoryHandler {
|
||||
}
|
||||
});
|
||||
if found {
|
||||
self.state.record_activity("tech_debt", &format!("Resolved tech debt via WebSocket RPC: {}", debt_id), Some("resolved"));
|
||||
self.state.record_activity(
|
||||
"tech_debt",
|
||||
&format!("Resolved tech debt via WebSocket RPC: {}", debt_id),
|
||||
Some("resolved"),
|
||||
);
|
||||
let _ = self.state.event_bus_tx.send(crate::state::GenericEvent {
|
||||
topic: "tech_debt:event".to_string(),
|
||||
session_id: None,
|
||||
@@ -832,7 +858,10 @@ impl MemoryHandler {
|
||||
"status": "resolved"
|
||||
}),
|
||||
});
|
||||
Some(crate::mcp::success(id, serde_json::json!({ "status": "success", "message": format!("Tech debt {} resolved", debt_id) })))
|
||||
Some(crate::mcp::success(
|
||||
id,
|
||||
serde_json::json!({ "status": "success", "message": format!("Tech debt {} resolved", debt_id) }),
|
||||
))
|
||||
} else {
|
||||
Some(crate::mcp::error(id, -32602, "Tech debt not found"))
|
||||
}
|
||||
@@ -853,13 +882,20 @@ impl MemoryHandler {
|
||||
}
|
||||
});
|
||||
if found {
|
||||
self.state.record_activity("gate", &format!("Authorized push gate via WebSocket: {}", gate_id), Some("authorized"));
|
||||
self.state.record_activity(
|
||||
"gate",
|
||||
&format!("Authorized push gate via WebSocket: {}", gate_id),
|
||||
Some("authorized"),
|
||||
);
|
||||
let _ = self.state.event_bus_tx.send(crate::state::GenericEvent {
|
||||
topic: "gate:event".to_string(),
|
||||
session_id: None,
|
||||
payload: serde_json::json!({ "id": gate_id, "status": "authorized", "active_gate": "authorized" }),
|
||||
});
|
||||
Some(crate::mcp::success(id, serde_json::json!({ "status": "success" })))
|
||||
Some(crate::mcp::success(
|
||||
id,
|
||||
serde_json::json!({ "status": "success" }),
|
||||
))
|
||||
} else {
|
||||
Some(crate::mcp::error(id, -32602, "Gate not found"))
|
||||
}
|
||||
@@ -880,13 +916,20 @@ impl MemoryHandler {
|
||||
}
|
||||
});
|
||||
if found {
|
||||
self.state.record_activity("gate", &format!("Blocked push gate via WebSocket: {}", gate_id), Some("blocked"));
|
||||
self.state.record_activity(
|
||||
"gate",
|
||||
&format!("Blocked push gate via WebSocket: {}", gate_id),
|
||||
Some("blocked"),
|
||||
);
|
||||
let _ = self.state.event_bus_tx.send(crate::state::GenericEvent {
|
||||
topic: "gate:event".to_string(),
|
||||
session_id: None,
|
||||
payload: serde_json::json!({ "id": gate_id, "status": "blocked", "active_gate": "blocked" }),
|
||||
});
|
||||
Some(crate::mcp::success(id, serde_json::json!({ "status": "success" })))
|
||||
Some(crate::mcp::success(
|
||||
id,
|
||||
serde_json::json!({ "status": "success" }),
|
||||
))
|
||||
} else {
|
||||
Some(crate::mcp::error(id, -32602, "Gate not found"))
|
||||
}
|
||||
@@ -902,13 +945,20 @@ impl MemoryHandler {
|
||||
}
|
||||
});
|
||||
if removed {
|
||||
self.state.record_activity("gate", &format!("Deleted push gate via WebSocket: {}", gate_id), Some("deleted"));
|
||||
self.state.record_activity(
|
||||
"gate",
|
||||
&format!("Deleted push gate via WebSocket: {}", gate_id),
|
||||
Some("deleted"),
|
||||
);
|
||||
let _ = self.state.event_bus_tx.send(crate::state::GenericEvent {
|
||||
topic: "gate:event".to_string(),
|
||||
session_id: None,
|
||||
payload: serde_json::json!({ "id": gate_id, "status": "deleted" }),
|
||||
});
|
||||
Some(crate::mcp::success(id, serde_json::json!({ "status": "success" })))
|
||||
Some(crate::mcp::success(
|
||||
id,
|
||||
serde_json::json!({ "status": "success" }),
|
||||
))
|
||||
} else {
|
||||
Some(crate::mcp::error(id, -32602, "Gate not found"))
|
||||
}
|
||||
@@ -1003,7 +1053,10 @@ pub fn format_tool_activity_description(name: &str, args: &serde_json::Value) ->
|
||||
("Create Entities", names)
|
||||
}
|
||||
"hypotheses" => {
|
||||
let act = args.get("action").and_then(|v| v.as_str()).unwrap_or("manage");
|
||||
let act = args
|
||||
.get("action")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("manage");
|
||||
let hyp = args
|
||||
.get("hypothesis")
|
||||
.or_else(|| args.get("query"))
|
||||
@@ -1011,24 +1064,39 @@ pub fn format_tool_activity_description(name: &str, args: &serde_json::Value) ->
|
||||
.unwrap_or("");
|
||||
(
|
||||
"Hypotheses",
|
||||
format!("{}: {}", act, hyp).trim_end_matches(": ").to_string(),
|
||||
format!("{}: {}", act, hyp)
|
||||
.trim_end_matches(": ")
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
"agent_signals" => {
|
||||
let act = args.get("action").and_then(|v| v.as_str()).unwrap_or("signal");
|
||||
let act = args
|
||||
.get("action")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("signal");
|
||||
let sender = args.get("sender").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let st = args.get("signal_type").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let st = args
|
||||
.get("signal_type")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
(
|
||||
"Agent Signals",
|
||||
format!("{}: {} [{}]", act, sender, st).trim_end_matches(": ").to_string(),
|
||||
format!("{}: {} [{}]", act, sender, st)
|
||||
.trim_end_matches(": ")
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
"process_logs" => {
|
||||
let act = args.get("action").and_then(|v| v.as_str()).unwrap_or("logs");
|
||||
let act = args
|
||||
.get("action")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("logs");
|
||||
let file = args.get("file_path").and_then(|v| v.as_str()).unwrap_or("");
|
||||
(
|
||||
"Process Logs",
|
||||
format!("{}: {}", act, file).trim_end_matches(": ").to_string(),
|
||||
format!("{}: {}", act, file)
|
||||
.trim_end_matches(": ")
|
||||
.to_string(),
|
||||
)
|
||||
}
|
||||
_ => return name.to_string(),
|
||||
@@ -1053,8 +1121,8 @@ async fn execute_tool_span(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use tempfile::tempdir;
|
||||
use serde_json::json;
|
||||
use tempfile::tempdir;
|
||||
|
||||
#[test]
|
||||
fn test_format_tool_activity_description() {
|
||||
|
||||
Reference in new issue
Block a user