radkit-macros

Crates.ioradkit-macros
lib.rsradkit-macros
version0.0.2
created_at2025-11-13 10:25:44.259921+00
updated_at2025-11-13 10:25:44.259921+00
descriptionProcedural macros for the radkit agent framework
homepage
repositoryhttps://github.com/irshadnilam/radkit
max_upload_size
id1930824
size54,674
Irshad (irshadnilam)

documentation

README

radkit-macros

Procedural macros for the radkit agent framework.

Overview

This crate provides the #[skill] attribute macro for defining A2A-compliant agent skills with automatic metadata generation.

Usage

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![],
        })
    }
}

Required Parameters

  • 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)

Optional Parameters

  • 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: [])

MIME Type Validation

The macro validates input_modes and output_modes against a list of common MIME types:

  • Text types: text/plain, text/html, text/markdown, text/csv, etc.
  • Application types: application/json, application/xml, application/yaml, application/pdf, etc.
  • Image types: image/png, image/jpeg, image/svg+xml, etc.
  • Wildcards: */*, text/*, application/*, image/*

If an invalid MIME type is provided, you'll get a compile error with suggestions for similar valid types.

What Gets Generated

The macro generates:

  1. A static SkillMetadata constant named {STRUCT_NAME}_METADATA
  2. An implementation of the RegisteredSkill trait for your struct

This allows you to register the skill with an agent builder:

let agent = AgentBuilder::new()
    .with_skill(WeatherSkill)
    .build(runtime)?;

Integration with A2A Protocol

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.

License

MIT

Commit count: 0

cargo fmt