pub struct Handlers { /* private fields */ }Available on crate feature
async-client only.Expand description
The callbacks a Client uses to answer the harness.
Implementations§
Source§impl Handlers
impl Handlers
Sourcepub fn tool<F, Fut>(self, name: impl Into<String>, f: F) -> Self
pub fn tool<F, Fut>(self, name: impl Into<String>, f: F) -> Self
Registers the implementation of a client-side tool.
name must match the Tool declared on
HarnessOptions::tool; the harness
dispatches by name.
use antigravity_codes::handlers::Handlers;
use antigravity_codes::protocol::ToolResponse;
let handlers = Handlers::new().tool("clock", |call| async move {
ToolResponse::ok(call.id.unwrap_or_default(), r#"{"now":"2026-08-08T00:00:00Z"}"#)
});
assert!(handlers.handles_tool("clock"));Sourcepub fn on_hook<F, Fut>(self, f: F) -> Selfwhere
F: Fn(CallHookRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = CallHookResponse> + Send + 'static,
pub fn on_hook<F, Fut>(self, f: F) -> Selfwhere
F: Fn(CallHookRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = CallHookResponse> + Send + 'static,
Handles every lifecycle hook the session subscribed to.
Sourcepub fn on_policy<F, Fut>(self, f: F) -> Selfwhere
F: Fn(PolicyDecisionRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = PolicyDecisionResponse> + Send + 'static,
pub fn on_policy<F, Fut>(self, f: F) -> Selfwhere
F: Fn(PolicyDecisionRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = PolicyDecisionResponse> + Send + 'static,
Adjudicates dynamic policy rules.
Sourcepub fn on_questions<F, Fut>(self, f: F) -> Selfwhere
F: Fn(UserQuestionsRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = UserQuestionsResponse> + Send + 'static,
pub fn on_questions<F, Fut>(self, f: F) -> Selfwhere
F: Fn(UserQuestionsRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = UserQuestionsResponse> + Send + 'static,
Answers questions the agent puts to the user.
Sourcepub fn on_tool_confirmation<F, Fut>(self, f: F) -> Self
pub fn on_tool_confirmation<F, Fut>(self, f: F) -> Self
Approves or refuses a tool the harness wants confirmed before running.
The handler receives the whole StepUpdate, because the action being
confirmed — the command line, the file path, the diff — is on the step,
not on the (empty) request itself.
Sourcepub fn handles_tool(&self, name: &str) -> bool
pub fn handles_tool(&self, name: &str) -> bool
Whether a tool of this name has an implementation registered.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Handlers
impl !UnwindSafe for Handlers
impl Freeze for Handlers
impl Send for Handlers
impl Sync for Handlers
impl Unpin for Handlers
impl UnsafeUnpin for Handlers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more