(spec: PyWorkerAgentSpec)
| 4654 | } |
| 4655 | |
| 4656 | fn py_worker_agent_spec_to_rust(spec: PyWorkerAgentSpec) -> PyResult<RustWorkerAgentSpec> { |
| 4657 | if spec.name.trim().is_empty() { |
| 4658 | return Err(PyValueError::new_err("worker agent name is required")); |
| 4659 | } |
| 4660 | if spec.description.trim().is_empty() { |
| 4661 | return Err(PyValueError::new_err( |
| 4662 | "worker agent description is required", |
| 4663 | )); |
| 4664 | } |
| 4665 | |
| 4666 | let mut worker = RustWorkerAgentSpec::new( |
| 4667 | parse_py_worker_agent_kind(&spec.kind)?, |
| 4668 | spec.name, |
| 4669 | spec.description, |
| 4670 | ) |
| 4671 | .hidden(spec.hidden); |
| 4672 | if let Some(policy) = spec.permissions { |
| 4673 | worker = worker.with_permissions(py_permission_policy_to_rust(policy)?); |
| 4674 | } |
| 4675 | if let Some(model) = spec.model { |
| 4676 | worker = worker.with_model(RustAgentModelConfig::from_model_ref(model)); |
| 4677 | } |
| 4678 | if let Some(prompt) = spec.prompt { |
| 4679 | worker = worker.with_prompt(prompt); |
| 4680 | } |
| 4681 | if let Some(max_steps) = spec.max_steps { |
| 4682 | worker = worker.with_max_steps(max_steps); |
| 4683 | } |
| 4684 | if let Some(ci) = spec.confirmation_inheritance { |
| 4685 | worker = worker.with_confirmation(parse_py_confirmation_inheritance(&ci)?); |
| 4686 | } |
| 4687 | Ok(worker) |
| 4688 | } |
| 4689 | |
| 4690 | fn parse_py_confirmation_inheritance( |
| 4691 | value: &str, |
no test coverage detected