logging: include runtime and skill versions

This commit is contained in:
zyl
2026-03-30 00:31:08 +08:00
parent c7d3d45c68
commit f7e2ff256e
6 changed files with 82 additions and 81 deletions

View File

@@ -5,7 +5,7 @@ use std::time::Duration;
use common::MockTransport;
use sgclaw::agent::handle_browser_message;
use sgclaw::pipe::{Action, AgentMessage, BrowserMessage, BrowserPipeTool, Timing};
use sgclaw::pipe::{AgentMessage, BrowserMessage, BrowserPipeTool};
use sgclaw::security::MacPolicy;
fn test_policy() -> MacPolicy {
@@ -23,39 +23,8 @@ fn test_policy() -> MacPolicy {
}
#[test]
fn submit_task_sends_three_commands_and_finishes_with_task_complete() {
let transport = Arc::new(MockTransport::new(vec![
BrowserMessage::Response {
seq: 1,
success: true,
data: serde_json::json!({ "navigated": true }),
aom_snapshot: vec![],
timing: Timing {
queue_ms: 1,
exec_ms: 20,
},
},
BrowserMessage::Response {
seq: 2,
success: true,
data: serde_json::json!({ "typed": true }),
aom_snapshot: vec![],
timing: Timing {
queue_ms: 1,
exec_ms: 20,
},
},
BrowserMessage::Response {
seq: 3,
success: true,
data: serde_json::json!({ "clicked": true }),
aom_snapshot: vec![],
timing: Timing {
queue_ms: 1,
exec_ms: 20,
},
},
]));
fn submit_task_without_llm_configuration_returns_clear_error() {
let transport = Arc::new(MockTransport::new(vec![]));
let tool = BrowserPipeTool::new(
transport.clone(),
test_policy(),
@@ -78,45 +47,15 @@ fn submit_task_sends_three_commands_and_finishes_with_task_complete() {
let sent = transport.sent_messages();
assert_eq!(sent.len(), 8);
assert_eq!(sent.len(), 2);
assert!(matches!(
&sent[0],
AgentMessage::LogEntry { level, message }
if level == "mode" && message == "deterministic_planner"
if level == "info" && message == "sgclaw runtime version=0.1.0 protocol=1.0"
));
assert!(matches!(
&sent[1],
AgentMessage::LogEntry { level, message }
if level == "info" && message == "navigate https://www.baidu.com"
));
assert!(matches!(
&sent[2],
AgentMessage::Command { seq, action, .. }
if *seq == 1 && action == &Action::Navigate
));
assert!(matches!(
&sent[3],
AgentMessage::LogEntry { level, message }
if level == "info" && message == "type 天气 into #kw"
));
assert!(matches!(
&sent[4],
AgentMessage::Command { seq, action, .. }
if *seq == 2 && action == &Action::Type
));
assert!(matches!(
&sent[5],
AgentMessage::LogEntry { level, message }
if level == "info" && message == "click #su"
));
assert!(matches!(
&sent[6],
AgentMessage::Command { seq, action, .. }
if *seq == 3 && action == &Action::Click
));
assert!(matches!(
&sent[7],
AgentMessage::TaskComplete { success, summary }
if *success && summary == "已在百度搜索天气"
if !success && summary.contains("未配置大语言模型")
));
}