| 2810 | /// @param configSource - Path to a config file (.acl), or inline config string |
| 2811 | #[napi(factory)] |
| 2812 | pub async fn create(config_source: String) -> napi::Result<Self> { |
| 2813 | let agent = get_runtime() |
| 2814 | .spawn(async move { RustAgent::new(config_source).await }) |
| 2815 | .await |
| 2816 | .map_err(|e| napi::Error::from_reason(format!("Task join error: {e}")))? |
| 2817 | .map_err(|e| napi::Error::from_reason(format!("Failed to create agent: {e}")))?; |
| 2818 | |
| 2819 | Ok(Self { |
| 2820 | inner: Arc::new(agent), |
| 2821 | }) |
| 2822 | } |
| 2823 | |
| 2824 | /// Re-fetch tool definitions from all connected global MCP servers and |
| 2825 | /// update the agent-level cache. |