feat: persist sgclaw browser conversations

This commit is contained in:
zyl
2026-03-27 01:57:42 +08:00
parent bae0e452a5
commit d315c13f66
11 changed files with 402 additions and 20 deletions

View File

@@ -8,13 +8,20 @@ type HmacSha256 = Hmac<Sha256>;
#[test]
fn browser_submit_task_round_trip_uses_task_wire_format() {
let raw = r#"{"type":"submit_task","instruction":"打开百度并搜索今日汇率"}"#;
let raw = r#"{"type":"submit_task","instruction":"打开百度并搜索今日汇率","conversation_id":"conversation-1","messages":[{"role":"assistant","content":"上一轮完成"}],"page_url":"https://www.baidu.com/","page_title":"百度一下"}"#;
let message: BrowserMessage = serde_json::from_str(raw).unwrap();
assert_eq!(
message,
BrowserMessage::SubmitTask {
instruction: "打开百度并搜索今日汇率".to_string(),
conversation_id: "conversation-1".to_string(),
messages: vec![sgclaw::pipe::ConversationMessage {
role: "assistant".to_string(),
content: "上一轮完成".to_string(),
}],
page_url: "https://www.baidu.com/".to_string(),
page_title: "百度一下".to_string(),
}
);
assert_eq!(serde_json::to_string(&message).unwrap(), raw);