Expand description
Type-safe session management for multi-turn conversations.
The Session struct consolidates session control into a single abstraction
that prevents conflicting session flags at the type level. Instead of
independently calling .continue_session(), .resume(), .session_id(),
or .fork_session() on a QueryCommand (which can
be combined incorrectly), a Session encodes the session mode in its
construction and provides .query() with automatic resume behavior.
§Example
use claude_wrapper::{Claude, QueryCommand};
use claude_wrapper::session::Session;
let claude = Claude::builder().build()?;
// Start a session with an initial query
let first = QueryCommand::new("explain quicksort")
.execute_json(&claude)
.await?;
// Wrap it in a Session for automatic resume
let mut session = Session::from_result(&claude, &first);
// Follow-up queries auto-resume the session
let second = session.query("now explain mergesort")
.model("sonnet")
.execute()
.await?;
println!("total cost: ${:.4}", session.total_cost_usd());
println!("total turns: {}", session.total_turns());Structs§
- Session
- A type-safe session handle for multi-turn conversations.
- Session
Query - Builder for a follow-up query within a session.