Skip to main content

muse_codes/
lib.rs

1//! # muse-codes
2//!
3//! Typed Rust SDK for [Meta's Muse Code](https://dev.meta.ai/docs) terminal
4//! coding agent. Models the machine-readable JSONL event stream of headless
5//! runs (`muse exec --json`): an event-sourced journal of envelope records
6//! ([`MuseRecord`]) whose payloads cover command intake, run lifecycle,
7//! task lifecycle, and streamed output.
8//!
9//! Types are derived from **captured real CLI output** (committed under
10//! `test_cases/`), captured via the credential-free `--provider echo` mode.
11//! Payload types not yet observed deserialize as [`MusePayload::Unknown`]
12//! rather than failing, and the envelope keeps the raw payload so
13//! round-trips are byte-faithful.
14//!
15//! ## Features
16//!
17//! - `types` — serde models only; `wasm32-unknown-unknown` compatible.
18//! - `async-client` (default) — Tokio client spawning `muse exec --json`.
19//!
20//! ## Quick start
21//!
22//! ```ignore
23//! use muse_codes::{ExecRun, MuseExecBuilder, MusePayload, Provider};
24//!
25//! let run = ExecRun::spawn(
26//!     &MuseExecBuilder::new("summarize this repo").provider(Provider::Meta),
27//! ).await?;
28//!
29//! let terminal = run.wait_terminal(|record| {
30//!     if let Ok(MusePayload::RunOutputDelta(d)) = record.typed_payload() {
31//!         print!("{}", d.text);
32//!     }
33//! }).await?;
34//! println!("\nterminal: {}", terminal.terminal);
35//! ```
36
37// Core modules always available
38pub mod error;
39pub mod io;
40pub mod version;
41
42// Client modules
43#[cfg(feature = "async-client")]
44pub mod auth;
45#[cfg(feature = "async-client")]
46pub mod cli;
47#[cfg(feature = "async-client")]
48pub mod client_async;
49
50pub use error::{Error, Result};
51pub use io::{
52    CommandAccepted, Durability, MusePayload, MuseRecord, RecordType, RunOutputDelta, RunStarted,
53    RunTerminal, SessionRunLinked, StreamKind, StreamRef, TaskLifecycle, TaskLifecycleEvent,
54    TaskStreamLinked, TurnInputUser,
55};
56
57#[cfg(feature = "async-client")]
58pub use cli::{MuseExecBuilder, Provider};
59#[cfg(feature = "async-client")]
60pub use client_async::ExecRun;