solana_ai_registries/
lib.rs

1//! # Solana AI Registries SDK
2//!
3//! This crate provides a Rust SDK for interacting with the Solana AI Registries,
4//! which includes both Agent Registry and MCP Server Registry protocols.
5//!
6//! ## Features
7//!
8//! - **Agent Registry**: Register, update, and manage autonomous agents
9//! - **MCP Server Registry**: Register, update, and manage Model Context Protocol servers
10//! - **Payment Systems**: Support for prepay, pay-as-you-go, and streaming payments
11//! - **Type Safety**: Fully typed requests and responses
12//! - **Error Handling**: Comprehensive error types matching on-chain program errors
13//!
14//! ## Feature Flags
15//!
16//! - `stream`: Enable streaming payment functionality
17//! - `pyg`: Enable pay-as-you-go payment functionality  
18//! - `prepay`: Enable prepaid payment functionality
19//!
20//! ## Example Usage
21//!
22//! ```rust,no_run
23//! use solana_ai_registries::{SolanaAiRegistriesClient, AgentBuilder};
24//! use solana_sdk::signer::keypair::Keypair;
25//!
26//! #[tokio::main]
27//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
28//!     // Create a client
29//!     let client = SolanaAiRegistriesClient::new("https://api.devnet.solana.com");
30//!     
31//!     // Build and register an agent
32//!     let agent = AgentBuilder::new("my-agent", "My AI Agent")
33//!         .description("An AI agent that does useful things")
34//!         .version("1.0.0")
35//!         .build()?;
36//!     
37//!     let keypair = Keypair::new();
38//!     let signature = client.register_agent(&keypair, agent).await?;
39//!     println!("Agent registered with signature: {}", signature);
40//!     
41//!     Ok(())
42//! }
43//! ```
44
45// Core modules
46pub mod client;
47pub mod errors;
48pub mod idl;
49
50// Registry modules
51pub mod agent;
52pub mod mcp;
53
54// Payment modules
55#[cfg(any(feature = "stream", feature = "pyg", feature = "prepay"))]
56pub mod payments;
57
58// Re-export commonly used types
59pub use client::{deserialize_account_data, SolanaAiRegistriesClient};
60pub use errors::{SdkError, SdkResult};
61
62// Re-export agent types
63pub use agent::{
64    AgentArgs, AgentBuilder, AgentEntry, AgentPatch, AgentRegistry, AgentSkill, AgentStatus,
65    ServiceEndpoint,
66};
67
68// Re-export MCP types
69pub use mcp::{
70    McpPromptDefinition, McpResourceDefinition, McpServerArgs, McpServerBuilder, McpServerEntry,
71    McpServerPatch, McpServerRegistry, McpServerStatus, McpToolDefinition,
72};
73
74// Re-export payment types conditionally
75#[cfg(feature = "stream")]
76pub use payments::stream::*;
77
78#[cfg(feature = "pyg")]
79pub use payments::pyg::*;
80
81#[cfg(feature = "prepay")]
82pub use payments::prepay::*;
83
84// Re-export Solana types for convenience
85pub use solana_sdk::{
86    pubkey::Pubkey,
87    signature::{Signature, Signer},
88    signer::keypair::Keypair,
89};
90
91/// SDK version
92pub const VERSION: &str = env!("CARGO_PKG_VERSION");
93
94/// Current registry versions supported
95pub const AGENT_REGISTRY_VERSION: u8 = 1;
96pub const MCP_SERVER_REGISTRY_VERSION: u8 = 1;