| Crates.io | radkit-macros |
| lib.rs | radkit-macros |
| version | 0.0.2 |
| created_at | 2025-11-13 10:25:44.259921+00 |
| updated_at | 2025-11-13 10:25:44.259921+00 |
| description | Procedural macros for the radkit agent framework |
| homepage | |
| repository | https://github.com/irshadnilam/radkit |
| max_upload_size | |
| id | 1930824 |
| size | 54,674 |
Procedural macros for the radkit agent framework.
This crate provides the #[skill] attribute macro for defining A2A-compliant agent skills with automatic metadata generation.
Add the macro to your skill struct and it will automatically generate the required SkillMetadata and implement the RegisteredSkill trait:
use radkit::prelude::*;
use radkit_macro::skill;
#[skill(
id = "weather_checker",
name = "Weather Checker",
description = "Fetches weather information for any location",
tags = ["weather", "api", "location"],
examples = [
"What's the weather in London?",
"Check the forecast for Tokyo"
],
input_modes = ["text/plain"],
output_modes = ["application/json", "text/plain"]
)]
pub struct WeatherSkill;
#[async_trait]
impl SkillHandler for WeatherSkill {
async fn on_request(
&self,
task_context: &mut TaskContext,
context: &Context,
runtime: &dyn Runtime,
content: Content,
) -> Result<OnRequestResult, AgentError> {
// Your skill implementation here
Ok(OnRequestResult::Completed {
message: Some(Content::from_text("Weather data retrieved")),
artifacts: vec![],
})
}
}
id: A unique identifier for the skill (String)name: A human-readable name for the skill (String)description: A detailed description of what the skill does (String)tags: Array of keywords describing the skill's capabilities (default: [])examples: Array of example prompts or scenarios (default: [])input_modes: Array of supported input MIME types (default: [])output_modes: Array of supported output MIME types (default: [])The macro validates input_modes and output_modes against a list of common MIME types:
text/plain, text/html, text/markdown, text/csv, etc.application/json, application/xml, application/yaml, application/pdf, etc.image/png, image/jpeg, image/svg+xml, etc.*/*, text/*, application/*, image/*If an invalid MIME type is provided, you'll get a compile error with suggestions for similar valid types.
The macro generates:
SkillMetadata constant named {STRUCT_NAME}_METADATARegisteredSkill trait for your structThis allows you to register the skill with an agent builder:
let agent = AgentBuilder::new()
.with_skill(WeatherSkill)
.build(runtime)?;
The generated metadata is used to create the AgentSkill entries in your agent's AgentCard, making your skills discoverable and callable via the A2A protocol.
MIT