feat: realign zhihu browser callback runtime
Keep Zhihu browser-attached execution on the callback-host path so direct routes, runtime wiring, and service startup stay aligned for the current websocket browser flow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -50,6 +50,7 @@ pub fn execute_task_with_browser_backend(
|
||||
instruction,
|
||||
task_context,
|
||||
route,
|
||||
settings,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -75,6 +76,7 @@ pub fn execute_task_with_browser_backend(
|
||||
instruction,
|
||||
task_context,
|
||||
route,
|
||||
settings,
|
||||
)
|
||||
}
|
||||
(_, Ok(summary)) => Ok(summary),
|
||||
@@ -85,6 +87,7 @@ pub fn execute_task_with_browser_backend(
|
||||
instruction,
|
||||
task_context,
|
||||
route,
|
||||
settings,
|
||||
),
|
||||
(None, Err(err)) => Err(err),
|
||||
}
|
||||
@@ -112,6 +115,7 @@ pub fn execute_task_with_sgclaw_settings<T: Transport + 'static>(
|
||||
instruction,
|
||||
task_context,
|
||||
route,
|
||||
settings,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -137,6 +141,7 @@ pub fn execute_task_with_sgclaw_settings<T: Transport + 'static>(
|
||||
instruction,
|
||||
task_context,
|
||||
route,
|
||||
settings,
|
||||
)
|
||||
}
|
||||
(_, Ok(summary)) => Ok(summary),
|
||||
@@ -147,6 +152,7 @@ pub fn execute_task_with_sgclaw_settings<T: Transport + 'static>(
|
||||
instruction,
|
||||
task_context,
|
||||
route,
|
||||
settings,
|
||||
),
|
||||
(None, Err(err)) => Err(err),
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use crate::compat::config_adapter::{
|
||||
build_zeroclaw_config_from_sgclaw_settings, resolve_skills_dir_from_sgclaw_settings,
|
||||
};
|
||||
use crate::compat::event_bridge::log_entry_for_turn_event;
|
||||
use crate::compat::workflow_executor::parse_generated_article_draft;
|
||||
use crate::compat::openxml_office_tool::OpenXmlOfficeTool;
|
||||
use crate::compat::screen_html_export_tool::ScreenHtmlExportTool;
|
||||
use crate::config::{DeepSeekSettings, OfficeBackend, SgClawSettings};
|
||||
@@ -101,6 +102,43 @@ pub fn execute_task_with_sgclaw_settings<T: Transport + 'static>(
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn generate_zhihu_article_draft(
|
||||
instruction: &str,
|
||||
topic: &str,
|
||||
_task_context: &CompatTaskContext,
|
||||
workspace_root: &Path,
|
||||
settings: &SgClawSettings,
|
||||
) -> Result<crate::compat::workflow_executor::ArticleDraft, PipeError> {
|
||||
let mut generation_settings = settings.clone();
|
||||
generation_settings.runtime_profile = crate::runtime::RuntimeProfile::GeneralAssistant;
|
||||
|
||||
let config = build_zeroclaw_config_from_sgclaw_settings(workspace_root, &generation_settings);
|
||||
let provider = build_provider(&config)?;
|
||||
let runtime = tokio::runtime::Runtime::new()
|
||||
.map_err(|err| PipeError::Protocol(format!("failed to create tokio runtime: {err}")))?;
|
||||
let generation_prompt = format!(
|
||||
"为知乎文章生成可直接发布的草稿。用户原始请求:{instruction}\n\n主题:{topic}\n\n请严格只输出以下格式,不要添加解释、前言、代码块或其他内容:\n标题:<简洁具体的中文标题>\n正文:<适合知乎发布的中文正文,使用自然段>"
|
||||
);
|
||||
|
||||
let generated = runtime.block_on(async move {
|
||||
provider
|
||||
.chat_with_system(
|
||||
Some("You write concise Chinese Zhihu article drafts. Return only the requested title/body format."),
|
||||
&generation_prompt,
|
||||
config.default_model.as_deref().unwrap_or("deepseek-chat"),
|
||||
config.default_temperature,
|
||||
)
|
||||
.await
|
||||
.map_err(map_anyhow_to_pipe_error)
|
||||
})?;
|
||||
|
||||
parse_generated_article_draft(&generated).ok_or_else(|| {
|
||||
PipeError::Protocol(format!(
|
||||
"generated Zhihu article draft did not match 标题/正文 format: {generated}"
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn execute_task_with_provider(
|
||||
transport: &dyn crate::agent::AgentEventSink,
|
||||
browser_backend: Arc<dyn BrowserBackend>,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user