| 566 | callback: "object" |
| 567 | ) -> "None", text_signature = "(name: str, priority: int, break_chain: bool, callback: object) -> None")] |
| 568 | fn register_tool_request_intercept( |
| 569 | &self, |
| 570 | name: &str, |
| 571 | priority: i32, |
| 572 | break_chain: bool, |
| 573 | callback: Py<PyAny>, |
| 574 | ) -> PyResult<()> { |
| 575 | let qualified_name = self.qualify_name(name); |
| 576 | register_tool_request_intercept( |
| 577 | &qualified_name, |
| 578 | priority, |
| 579 | break_chain, |
| 580 | wrap_py_tool_request_intercept_fn(callback), |
| 581 | ) |
| 582 | .map_err(to_py_err)?; |
| 583 | |
| 584 | let name_owned = qualified_name; |
| 585 | let mut guard = self.registrations.lock().map_err(|e| { |
| 586 | pyo3::exceptions::PyRuntimeError::new_err(format!("plugin context lock poisoned: {e}")) |
| 587 | })?; |
| 588 | guard.push(PluginRegistration::new( |
| 589 | "plugin", |
| 590 | name_owned.clone(), |
| 591 | Box::new(move || { |
| 592 | deregister_tool_request_intercept(&name_owned) |
| 593 | .map(|_| ()) |
| 594 | .map_err(|e| { |
| 595 | PluginError::RegistrationFailed(format!( |
| 596 | "tool request intercept deregistration failed: {e}" |
| 597 | )) |
| 598 | }) |
| 599 | }), |
| 600 | )); |
| 601 | Ok(()) |
| 602 | } |
| 603 | |
| 604 | #[pyo3(signature = (name: "str", priority: "int", callback: "object") -> "None", text_signature = "(name: str, priority: int, callback: object) -> None")] |
| 605 | fn register_tool_execution_intercept( |