(
&self,
prompt: String,
attachments: Vec<AttachmentObject>,
history: Option<Vec<MessageObject>>,
)
| 3464 | /// @param history - Optional conversation history |
| 3465 | #[napi] |
| 3466 | pub async fn send_with_attachments( |
| 3467 | &self, |
| 3468 | prompt: String, |
| 3469 | attachments: Vec<AttachmentObject>, |
| 3470 | history: Option<Vec<MessageObject>>, |
| 3471 | ) -> napi::Result<AgentResult> { |
| 3472 | let rust_attachments = js_attachments_to_rust(&attachments); |
| 3473 | let rust_history = history.map(|h| js_messages_to_rust(&h)).transpose()?; |
| 3474 | let session = self.inner.clone(); |
| 3475 | let result = get_runtime() |
| 3476 | .spawn(async move { |
| 3477 | session |
| 3478 | .send_with_attachments(&prompt, &rust_attachments, rust_history.as_deref()) |
| 3479 | .await |
| 3480 | }) |
| 3481 | .await |
| 3482 | .map_err(|e| napi::Error::from_reason(format!("Task join error: {e}")))? |
| 3483 | .map_err(|e| napi::Error::from_reason(format!("Agent execution failed: {e}")))?; |
| 3484 | Ok(AgentResult::from(result)) |
| 3485 | } |
| 3486 | |
| 3487 | /// Stream a prompt with image attachments. |
| 3488 | /// |
no test coverage detected