feat: add browser script skill execution

This commit is contained in:
zyl
2026-03-30 02:15:07 +08:00
parent f7e2ff256e
commit d2c9902966
22 changed files with 1775 additions and 249 deletions

View File

@@ -1,4 +1,6 @@
use sgclaw::pipe::{Action, AgentMessage, BrowserMessage, SecurityFields, Timing};
use sgclaw::pipe::{
Action, AgentMessage, BrowserMessage, ExecutionSurfaceKind, SecurityFields, Timing,
};
#[test]
fn browser_init_round_trip_uses_frozen_wire_format() {
@@ -57,3 +59,32 @@ fn response_deserializes_timing_and_payload() {
}
);
}
#[test]
fn submit_task_exposes_browser_context_without_implying_browser_only_runtime() {
let message = BrowserMessage::SubmitTask {
instruction: "统计一下知乎热榜".to_string(),
conversation_id: "conversation-1".to_string(),
messages: vec![],
page_url: "https://www.zhihu.com/hot".to_string(),
page_title: "知乎热榜".to_string(),
};
let context = message.browser_context().expect("browser context");
let surface = message
.requested_surface_metadata()
.expect("surface metadata");
assert_eq!(context.page_url, "https://www.zhihu.com/hot");
assert_eq!(context.page_title, "知乎热榜");
assert_eq!(surface.kind, ExecutionSurfaceKind::PrivilegedBrowserPipe);
assert!(surface.privileged);
assert!(!surface.defines_runtime_identity);
}
#[test]
fn supported_actions_include_browser_script_execution() {
let supported = sgclaw::pipe::supported_actions();
assert!(supported.iter().any(|action| action.as_str() == "eval"));
}