Build RustSessionOptions from PySessionOptions.
(so: PySessionOptions)
| 5880 | |
| 5881 | /// Build RustSessionOptions from PySessionOptions. |
| 5882 | fn build_rust_session_options(so: PySessionOptions) -> PyResult<RustSessionOptions> { |
| 5883 | let mut o = RustSessionOptions::new(); |
| 5884 | if let Some(m) = so.model { |
| 5885 | o = o.with_model(m); |
| 5886 | } |
| 5887 | if so.builtin_skills { |
| 5888 | o = o.with_builtin_skills(); |
| 5889 | } |
| 5890 | for d in &so.skill_dirs { |
| 5891 | o = o.with_skills_from_dir(d); |
| 5892 | } |
| 5893 | if let Some(enabled) = so.enforce_active_skill_tool_restrictions { |
| 5894 | o = o.with_active_skill_tool_restrictions(enabled); |
| 5895 | } |
| 5896 | for d in &so.agent_dirs { |
| 5897 | o = o.with_agent_dir(d); |
| 5898 | } |
| 5899 | for worker in so.worker_agents { |
| 5900 | o = o.with_worker_agent(py_worker_agent_spec_to_rust(worker)?); |
| 5901 | } |
| 5902 | if let Some(qc) = so.queue_config { |
| 5903 | o = o.with_queue_config(qc.inner); |
| 5904 | } |
| 5905 | if let Some(policy) = so.permission_policy { |
| 5906 | o = o.with_permission_checker(Arc::new(py_permission_policy_to_rust(policy)?)); |
| 5907 | } |
| 5908 | if let Some(policy) = so.confirmation_policy { |
| 5909 | o = o.with_confirmation_policy(py_confirmation_policy_to_rust(policy)?); |
| 5910 | } |
| 5911 | if so.auto_compact { |
| 5912 | o = o.with_auto_compact(true); |
| 5913 | } |
| 5914 | if let Some(t) = so.auto_compact_threshold { |
| 5915 | o = o.with_auto_compact_threshold(t); |
| 5916 | } |
| 5917 | if let Some(limits) = so.artifact_store_limits { |
| 5918 | o = o.with_artifact_store_limits(limits.into()); |
| 5919 | } |
| 5920 | if let Some(ref store) = so.memory_store { |
| 5921 | let dir = Python::with_gil(|py| { |
| 5922 | store |
| 5923 | .extract::<pyo3::PyRef<PyFileMemoryStore>>(py) |
| 5924 | .ok() |
| 5925 | .map(|s| s.dir.clone()) |
| 5926 | }); |
| 5927 | if let Some(dir) = dir { |
| 5928 | o = o.with_file_memory(dir); |
| 5929 | } |
| 5930 | } |
| 5931 | if let Some(ref store) = so.session_store { |
| 5932 | enum SessionStoreKind { |
| 5933 | File(String), |
| 5934 | Memory, |
| 5935 | } |
| 5936 | let kind = Python::with_gil(|py| { |
| 5937 | if let Ok(file_store) = store.extract::<pyo3::PyRef<PyFileSessionStore>>(py) { |
| 5938 | Some(SessionStoreKind::File(file_store.dir.clone())) |
| 5939 | } else if store |