1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! # Codex SDK for Rust
//!
//! Embed Codex in Rust applications by wrapping the `codex` CLI and exchanging
//! JSONL events over stdin/stdout.
//!
//! ## When To Use Which API
//!
//! - Use [`Thread::run`] when you only need the final turn result.
//! - Use [`Thread::run_streamed`] when you need progress events while the turn runs.
//! - Use [`Codex::resume_thread`] when continuing an existing saved thread.
//!
//! ## Quickstart
//!
//! ```rust,no_run
//! use codex::Codex;
//!
//! # async fn example() -> codex::Result<()> {
//! let codex = Codex::new(None)?;
//! let thread = codex.start_thread(None);
//! let turn = thread
//! .run("Diagnose the test failure and propose a fix", None)
//! .await?;
//!
//! println!("response: {}", turn.final_response);
//! # Ok(())
//! # }
//! ```
//!
//! ## Continue The Same Thread
//!
//! ```rust,no_run
//! use codex::Codex;
//!
//! # async fn example() -> codex::Result<()> {
//! let codex = Codex::new(None)?;
//! let thread = codex.start_thread(None);
//! let _first = thread.run("Inspect failing tests", None).await?;
//! let second = thread.run("Apply a fix", None).await?;
//! println!("{}", second.final_response);
//! # Ok(())
//! # }
//! ```
//!
//! ## Stream Events
//!
//! ```rust,no_run
//! use codex::{Codex, ThreadEvent};
//! use futures::StreamExt;
//!
//! # async fn example() -> codex::Result<()> {
//! let codex = Codex::new(None)?;
//! let thread = codex.start_thread(None);
//! let mut events = thread.run_streamed("Analyze repository state", None).await?.events;
//!
//! while let Some(event) = events.next().await {
//! if let ThreadEvent::TurnCompleted { usage } = event? {
//! println!("usage: {:?}", usage);
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Structured Output
//!
//! ```rust,no_run
//! use codex::{Codex, TurnOptions};
//! use serde_json::json;
//!
//! # async fn example() -> codex::Result<()> {
//! let codex = Codex::new(None)?;
//! let thread = codex.start_thread(None);
//! let schema = json!({
//! "type": "object",
//! "properties": { "summary": { "type": "string" } },
//! "required": ["summary"],
//! "additionalProperties": false
//! });
//!
//! let turn = thread
//! .run(
//! "Summarize the repository status",
//! Some(TurnOptions {
//! output_schema: Some(schema),
//! ..Default::default()
//! }),
//! )
//! .await?;
//! println!("{}", turn.final_response);
//! # Ok(())
//! # }
//! ```
/// High-level client used to start and resume Codex threads.
/// Client-level options, environment configuration, and `--config` overrides.
/// Shared error types and `Result` alias.
/// Stream event payloads emitted by `codex exec --experimental-json`.
/// Low-level subprocess execution layer for invoking the Codex CLI.
/// Canonical item payloads produced inside a thread turn.
/// Temporary output-schema file helpers for structured output turns.
/// Thread and turn execution APIs (`run` and `run_streamed`).
/// Per-thread execution options mapped to Codex CLI flags/config.
/// Per-turn options such as output schema and cancellation support.
pub use Codex;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use TurnOptions;
/// The version of the Codex Rust SDK, sourced from `Cargo.toml`.
pub const SDK_VERSION: &str = env!;