(
&self,
workspace: String,
agent_name: String,
agent_dirs: Option<Vec<String>>,
options: Option<SessionOptions>,
)
| 2897 | /// @param options - Optional session overrides layered on top of the agent definition |
| 2898 | #[napi] |
| 2899 | pub fn session_for_agent( |
| 2900 | &self, |
| 2901 | workspace: String, |
| 2902 | agent_name: String, |
| 2903 | agent_dirs: Option<Vec<String>>, |
| 2904 | options: Option<SessionOptions>, |
| 2905 | ) -> napi::Result<Session> { |
| 2906 | let registry = a3s_code_core::subagent::AgentRegistry::new(); |
| 2907 | for dir in agent_dirs.unwrap_or_default() { |
| 2908 | let agents = a3s_code_core::subagent::load_agents_from_dir(std::path::Path::new(&dir)); |
| 2909 | for agent in agents { |
| 2910 | registry.register(agent); |
| 2911 | } |
| 2912 | } |
| 2913 | let def = registry |
| 2914 | .get(&agent_name) |
| 2915 | .ok_or_else(|| napi::Error::from_reason(format!("agent '{}' not found", agent_name)))?; |
| 2916 | let session = self |
| 2917 | .inner |
| 2918 | .session_for_agent( |
| 2919 | workspace, |
| 2920 | &def, |
| 2921 | options |
| 2922 | .map(|o| js_session_options_to_rust(Some(o))) |
| 2923 | .transpose()?, |
| 2924 | ) |
| 2925 | .map_err(|e| napi::Error::from_reason(format!("{e}")))?; |
| 2926 | Ok(Session { |
| 2927 | inner: Arc::new(session), |
| 2928 | }) |
| 2929 | } |
| 2930 | |
| 2931 | /// Create a session pre-configured from a disposable worker spec. |
| 2932 | /// |
nothing calls this directly
no test coverage detected