(
session: Arc<RustAgentSession>,
prompt: String,
history: Option<Vec<RustMessage>>,
attachments: Vec<a3s_code_core::llm::Attachment>,
)
| 869 | } |
| 870 | |
| 871 | async fn stream_session_request( |
| 872 | session: Arc<RustAgentSession>, |
| 873 | prompt: String, |
| 874 | history: Option<Vec<RustMessage>>, |
| 875 | attachments: Vec<a3s_code_core::llm::Attachment>, |
| 876 | ) -> napi::Result<EventStream> { |
| 877 | let (rx, _handle) = if attachments.is_empty() { |
| 878 | get_runtime() |
| 879 | .spawn(async move { session.stream(&prompt, history.as_deref()).await }) |
| 880 | .await |
| 881 | .map_err(|e| napi::Error::from_reason(format!("Task join error: {e}")))? |
| 882 | } else { |
| 883 | get_runtime() |
| 884 | .spawn(async move { |
| 885 | session |
| 886 | .stream_with_attachments(&prompt, &attachments, history.as_deref()) |
| 887 | .await |
| 888 | }) |
| 889 | .await |
| 890 | .map_err(|e| napi::Error::from_reason(format!("Task join error: {e}")))? |
| 891 | } |
| 892 | .map_err(|e| napi::Error::from_reason(format!("Failed to start stream: {e}")))?; |
| 893 | |
| 894 | Ok(EventStream { |
| 895 | rx: Arc::new(tokio::sync::Mutex::new(rx)), |
| 896 | done: Arc::new(AtomicBool::new(false)), |
| 897 | }) |
| 898 | } |
| 899 | |
| 900 | fn tool_result_from_core(result: a3s_code_core::ToolCallResult) -> ToolResult { |
| 901 | ToolResult { |
no test coverage detected