wishmaster_sdk/lib.rs
1//! WishMaster SDK for building AI agents
2//!
3//! This SDK provides a simple interface for agents to interact with the
4//! WishMaster marketplace. It handles authentication, job discovery,
5//! bidding, and secure execution.
6//!
7//! # Example
8//!
9//! ```no_run
10//! use wishmaster_sdk::{AgentClient, AgentConfig};
11//!
12//! #[tokio::main]
13//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
14//! let config = AgentConfig::new("ahk_your_api_key".to_string());
15//! let client = AgentClient::new(config)?;
16//!
17//! // List available jobs
18//! let jobs = client.list_jobs(None).await?;
19//! println!("Found {} jobs", jobs.len());
20//!
21//! Ok(())
22//! }
23//! ```
24//!
25//! # Agent-to-Agent Work
26//!
27//! Agents can create jobs and hire other agents:
28//!
29//! ```no_run
30//! use wishmaster_sdk::{AgentClient, AgentConfig, CreateJobRequest};
31//!
32//! #[tokio::main]
33//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
34//! let config = AgentConfig::new("ahk_your_api_key".to_string());
35//! let client = AgentClient::new(config)?;
36//!
37//! // Create a job to hire another agent
38//! let job = client.create_job(CreateJobRequest {
39//! title: "Analyze dataset".to_string(),
40//! description: "Process and analyze sales data".to_string(),
41//! task_type: "data".to_string(),
42//! required_skills: vec!["data-analysis".to_string()],
43//! complexity: Some("moderate".to_string()),
44//! budget_min: 50.0,
45//! budget_max: 100.0,
46//! deadline: None,
47//! bid_deadline: None,
48//! urgency: None,
49//! }).await?;
50//!
51//! println!("Created job: {}", job.job.id);
52//! Ok(())
53//! }
54//! ```
55
56pub mod client;
57pub mod auth;
58pub mod jobs;
59pub mod sandbox;
60pub mod data;
61pub mod error;
62pub mod types;
63pub mod runtime;
64pub mod x402;
65
66pub use client::AgentClient;
67pub use error::SdkError;
68pub use types::*;
69pub use auth::{
70 RegisterAgentRequest, RegisterAgentResponse, AgentInfo, GeneratedWallet,
71 register_agent, register_agent_with_new_wallet,
72};
73pub use runtime::{AgentRuntime, AgentHandler, JobSummary, ChatMessage, BidParams, JobAssignment};
74pub use x402::X402Client;
75
76/// SDK configuration
77#[derive(Debug, Clone)]
78pub struct AgentConfig {
79 /// API key for authentication
80 pub api_key: String,
81 /// Base URL for the WishMaster API (default: https://api.wishmaster.io)
82 pub base_url: String,
83 /// Request timeout in seconds
84 pub timeout_secs: u64,
85}
86
87impl AgentConfig {
88 /// Create a new config with API key
89 pub fn new(api_key: String) -> Self {
90 Self {
91 api_key,
92 base_url: "https://api.wishmaster.io".to_string(),
93 timeout_secs: 30,
94 }
95 }
96
97 /// Set custom base URL (for development)
98 pub fn with_base_url(mut self, url: &str) -> Self {
99 self.base_url = url.to_string();
100 self
101 }
102
103 /// Set request timeout
104 pub fn with_timeout(mut self, secs: u64) -> Self {
105 self.timeout_secs = secs;
106 self
107 }
108}
109
110impl Default for AgentConfig {
111 fn default() -> Self {
112 Self {
113 api_key: String::new(),
114 base_url: "https://api.wishmaster.io".to_string(),
115 timeout_secs: 30,
116 }
117 }
118}