jules_rs/lib.rs
1//! # jules-rs
2//!
3//! A production-grade Rust client for the [Jules API](https://jules.google.com).
4//!
5//! Jules is Google's AI coding agent that can understand, plan, and execute
6//! coding tasks on your GitHub repositories.
7//!
8//! ## Quick Start
9//!
10//! ```rust,no_run
11//! use jules_rs::{JulesClient, Session, SourceContext, GitHubRepoContext};
12//!
13//! #[tokio::main]
14//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
15//! // Create a client with your API key from jules.google.com/settings
16//! let client = JulesClient::new("YOUR_API_KEY")?;
17//!
18//! // List all sessions
19//! let response = client.list_sessions(Some(10), None).await?;
20//! for session in response.sessions {
21//! println!("Session: {:?} - {:?}", session.id, session.title);
22//! }
23//!
24//! Ok(())
25//! }
26//! ```
27//!
28//! ## Features
29//!
30//! - **Sessions**: Create, list, get, and delete coding sessions
31//! - **Activities**: Track session activities and progress updates
32//! - **Sources**: List and query connected GitHub repositories
33//! - **Streaming**: Paginate through results with async streams
34//! - **Type-safe**: Full Rust types for all API models
35//!
36//! ## Authentication
37//!
38//! Obtain an API key from [jules.google.com/settings](https://jules.google.com/settings).
39//!
40//! ## Example: Create a Session
41//!
42//! ```rust,no_run
43//! use jules_rs::{JulesClient, Session, SourceContext, GitHubRepoContext};
44//!
45//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
46//! let client = JulesClient::new("YOUR_OAUTH_TOKEN")?;
47//!
48//! let session = Session {
49//! name: None,
50//! id: None,
51//! prompt: "Fix the bug in the login handler".to_string(),
52//! source_context: SourceContext {
53//! source: "sources/my-repo-id".to_string(),
54//! github_repo_context: Some(GitHubRepoContext {
55//! starting_branch: "main".to_string(),
56//! }),
57//! },
58//! title: Some("Fix login bug".to_string()),
59//! require_plan_approval: Some(true),
60//! automation_mode: None,
61//! create_time: None,
62//! update_time: None,
63//! state: None,
64//! url: None,
65//! outputs: None,
66//! };
67//!
68//! let created = client.create_session(&session).await?;
69//! println!("Created session: {}", created.name.unwrap());
70//! # Ok(())
71//! # }
72//! ```
73//!
74//! ## Example: Stream All Sessions
75//!
76//! ```rust,no_run
77//! use jules_rs::JulesClient;
78//! use futures_util::StreamExt;
79//!
80//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
81//! let client = JulesClient::new("YOUR_API_KEY")?;
82//!
83//! let mut stream = client.stream_sessions();
84//! while let Some(result) = stream.next().await {
85//! let session = result?;
86//! println!("Session: {:?}", session.title);
87//! }
88//! # Ok(())
89//! # }
90//! ```
91
92pub mod client;
93pub mod error;
94pub mod models;
95
96pub use client::JulesClient;
97pub use error::{JulesError, Result};
98pub use models::*;