scud/opencode/
mod.rs

1//! OpenCode Server integration
2//!
3//! Provides HTTP client and SSE event streaming for OpenCode Server mode.
4//! This module enables SCUD to communicate with OpenCode's headless server
5//! for agent orchestration with structured events and graceful cancellation.
6//!
7//! # Architecture
8//!
9//! ```text
10//! SCUD Swarm ──HTTP──► OpenCode Server (localhost:4096)
11//!                 ◄─SSE── real-time events
12//! ```
13//!
14//! # Usage
15//!
16//! ```no_run
17//! use scud::opencode::{OpenCodeClient, OpenCodeManager};
18//!
19//! #[tokio::main]
20//! async fn main() -> anyhow::Result<()> {
21//!     // Get global manager (auto-starts server if needed)
22//!     let manager = scud::opencode::global_manager();
23//!     manager.ensure_running().await?;
24//!
25//!     // Create session and send prompt
26//!     let client = manager.client();
27//!     let session = client.create_session("Task 1").await?;
28//!     client.send_message(&session.id, "Implement feature X", None).await?;
29//!
30//!     Ok(())
31//! }
32//! ```
33
34pub mod client;
35pub mod events;
36pub mod manager;
37pub mod orchestrator;
38pub mod types;
39
40pub use client::OpenCodeClient;
41pub use events::{EventStream, OpenCodeEvent};
42pub use manager::{global_manager, init_global_manager, OpenCodeManager, ServerConfig, DEFAULT_PORT};
43pub use orchestrator::{execute_wave_server, AgentHandle, AgentOrchestrator};
44pub use types::*;