MCPcopy Create free account
hub / github.com/AI45Lab/Code / stream_session_request

Function stream_session_request

sdk/node/src/lib.rs:871–898  ·  view source on GitHub ↗
(
    session: Arc<RustAgentSession>,
    prompt: String,
    history: Option<Vec<RustMessage>>,
    attachments: Vec<a3s_code_core::llm::Attachment>,
)

Source from the content-addressed store, hash-verified

869}
870
871async 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
900fn tool_result_from_core(result: a3s_code_core::ToolCallResult) -> ToolResult {
901 ToolResult {

Callers 2

streamMethod · 0.85
stream_requestMethod · 0.85

Calls 5

get_runtimeFunction · 0.70
is_emptyMethod · 0.45
spawnMethod · 0.45
streamMethod · 0.45

Tested by

no test coverage detected