oam-schema 0.3.0

Procedural macros for the ROAM Object Agent Mapping framework
Documentation

oam-schema

Procedural macros for the OAM (Object Agent Mapping) framework.

Overview

oam-schema provides derive macros that generate LLM-ready JSON schemas at compile time, enabling your Rust structs to be used directly as tool-calling parameter schemas for OpenAI, Anthropic, and other LLM providers.

Usage

Add to your Cargo.toml:

[dependencies]
oam-schema = "0.1"
schemars = { version = "0.8", features = ["derive"] }
serde = { version = "1", features = ["derive"] }

#[derive(LlmSchema)]

Generates an llm_schema() associated function that returns a schemars::schema::RootSchema — the standard format expected by LLM function-calling APIs.

use oam_schema::LlmSchema;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, JsonSchema, LlmSchema)]
pub struct CreateOrganization {
    pub name: String,
    pub slug: String,
    pub parent_id: Option<String>,
}

// Pass the schema to an LLM tool definition
let schema = CreateOrganization::llm_schema();
let schema_json = serde_json::to_value(&schema).unwrap();

License

Licensed under either of Apache License 2.0 or MIT License at your option.