1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Building blocks for skill-based A2A agents: a [`SkillHandler`] trait,
//! a [`SkillRegistry`] that maps skill ids to handlers, [`SkillCard`]
//! (a `SKILL.md` manifest projected to an A2A `AgentSkill`), and a
//! [`SkillProgressSink`] for progress updates.
//!
//! Use it when an agent exposes several named skills instead of one free-form
//! executor. The crate depends only on
//! [`turul-a2a-proto`](https://docs.rs/turul-a2a-proto) and
//! [`turul-a2a-types`](https://docs.rs/turul-a2a-types), not on the server;
//! wiring a registry into an executor is done with
//! [`turul-a2a`](https://docs.rs/turul-a2a).
//!
//! # Example
//!
//! ```toml
//! [dependencies]
//! turul-a2a-patterns = "0.2"
//! turul-a2a-proto = "0.2"
//! async-trait = "0.1"
//! serde_json = "1"
//! tokio = { version = "1", features = ["full"] }
//! ```
//!
//! ```rust
//! use std::sync::Arc;
//! use serde_json::{json, Value};
//! use turul_a2a_patterns::*;
//! use turul_a2a_proto::AgentSkill;
//!
//! struct Greet;
//!
//! #[async_trait::async_trait]
//! impl SkillHandler for Greet {
//! async fn run(&self, params: Value, _sink: &dyn SkillProgressSink)
//! -> Result<Value, SkillError>
//! {
//! let name = params["name"].as_str().unwrap_or("world");
//! Ok(json!({ "greeting": format!("hello {name}") }))
//! }
//! }
//!
//! # async fn run() -> Result<(), SkillError> {
//! let registry = InMemorySkillRegistry::new();
//! let skill = AgentSkill { id: "greet".into(), name: "Greet".into(), ..Default::default() };
//! registry.register_programmatic(skill, None, Arc::new(Greet)).await?;
//! assert!(registry.handler("greet").await.is_some());
//! # Ok(())
//! # }
//! ```
//!
//! # Where next
//!
//! - [`GatedHandler`] with a [`PreTerminalGate`] to veto a handler's output
//! before the task becomes terminal
//! - [`TerminalHook`] and [`SkillOutcome`] to observe how a skill ended
//! - [`SkillCard::from_embedded`] to load a `SKILL.md` manifest, with
//! [`validate_json`] for its input and output schemas
//! - [Examples](https://github.com/aussierobots/turul-a2a/tree/main/examples)
//! on GitHub
pub use ;
pub use ;
pub use SkillHandler;
pub use ;
pub use ;
pub use ;
pub use validate_json;
pub use ;