feat: align browser callback runtime and export flows
Consolidate the browser task runtime around the callback path, add safer artifact opening for Zhihu exports, and cover the new service/browser flows with focused tests and supporting docs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -40,13 +40,13 @@ impl AgentRuntimeContext {
|
||||
"missing value for --config-path".to_string(),
|
||||
));
|
||||
};
|
||||
config_path = Some(PathBuf::from(value));
|
||||
config_path = Some(resolve_process_path(PathBuf::from(value)));
|
||||
continue;
|
||||
}
|
||||
|
||||
let arg_string = arg.to_string_lossy();
|
||||
if let Some(value) = arg_string.strip_prefix("--config-path=") {
|
||||
config_path = Some(PathBuf::from(value));
|
||||
config_path = Some(resolve_process_path(PathBuf::from(value)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,37 @@ fn default_workspace_root() -> PathBuf {
|
||||
std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
|
||||
}
|
||||
|
||||
fn resolve_process_path(path: PathBuf) -> PathBuf {
|
||||
if path.is_absolute() {
|
||||
path
|
||||
} else {
|
||||
default_workspace_root().join(path)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn from_process_args_resolves_relative_config_path_against_current_dir() {
|
||||
let current_dir = std::env::current_dir().unwrap();
|
||||
let context = AgentRuntimeContext::from_process_args([
|
||||
OsString::from("sg_claw"),
|
||||
OsString::from("--config-path"),
|
||||
OsString::from("../tmp/sgclaw_config.json"),
|
||||
])
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
context.config_path,
|
||||
Some(current_dir.join("../tmp/sgclaw_config.json"))
|
||||
);
|
||||
assert_eq!(context.workspace_root, current_dir.join("../tmp"));
|
||||
assert!(context.workspace_root.is_absolute());
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct SubmitTaskRequest {
|
||||
pub instruction: String,
|
||||
|
||||
Reference in New Issue
Block a user