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
//! Periplon SDK - Multi-agent AI workflow orchestration
//!
//! This SDK provides a Rust interface for building and executing multi-agent AI workflows.
//! It communicates with the CLI via stdin/stdout using newline-delimited JSON (NDJSON).
//!
//! # Architecture
//!
//! The SDK follows **Hexagonal Architecture** (Ports and Adapters pattern):
//!
//! - **Domain Core**: Pure business logic (message types, sessions, permissions, hooks, control)
//! - **Primary Ports**: Inbound interfaces (AgentService, SessionManager, ControlProtocol)
//! - **Secondary Ports**: Outbound interfaces (Transport, PermissionService, HookService, McpServer)
//! - **Primary Adapters**: Implementations driving the application (query function, PeriplonSDKClient)
//! - **Secondary Adapters**: Implementations connecting to external systems (SubprocessCLITransport, MockTransport)
//! - **Application Services**: Orchestration layer (Query)
//!
//! # Examples
//!
//! ## Simple Query
//!
//! ```no_run
//! use periplon_sdk::{query, Message, ContentBlock};
//! use futures::StreamExt;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut stream = query("What is 2 + 2?", None).await?;
//!
//! while let Some(msg) = stream.next().await {
//! match msg {
//! Message::Assistant(assistant_msg) => {
//! for block in assistant_msg.message.content {
//! if let ContentBlock::Text { text } = block {
//! println!("Assistant: {}", text);
//! }
//! }
//! }
//! Message::Result(result_msg) => {
//! println!("Cost: ${:.4}", result_msg.total_cost_usd.unwrap_or(0.0));
//! }
//! _ => {}
//! }
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! ## Interactive Client
//!
//! ```no_run
//! use periplon_sdk::{PeriplonSDKClient, AgentOptions};
//! use futures::StreamExt;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let options = AgentOptions {
//! allowed_tools: vec!["Read".to_string(), "Bash".to_string()],
//! permission_mode: Some("acceptEdits".to_string()),
//! ..Default::default()
//! };
//!
//! let mut client = PeriplonSDKClient::new(options);
//! client.connect(None).await?;
//!
//! // First query
//! client.query("List files in current directory").await?;
//! {
//! let stream = client.receive_response()?;
//! futures::pin_mut!(stream);
//! while let Some(msg) = stream.next().await {
//! println!("{:?}", msg);
//! }
//! }
//!
//! // Follow-up query
//! client.query("Create a README.md file").await?;
//! {
//! let stream = client.receive_response()?;
//! futures::pin_mut!(stream);
//! while let Some(msg) = stream.next().await {
//! println!("{:?}", msg);
//! }
//! }
//!
//! client.disconnect().await?;
//!
//! Ok(())
//! }
//! ```
// Testing utilities - available in test/dev builds
// This allows integration tests in the tests/ directory to access these utilities
// Re-export commonly used types
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use TuiApp;