Skip to main content

Crate muse_codes

Crate muse_codes 

Source
Expand description

§muse-codes

Typed Rust SDK for Meta’s Muse Code terminal coding agent. Models the machine-readable JSONL event stream of headless runs (muse exec --json): an event-sourced journal of envelope records (MuseRecord) whose payloads cover command intake, run lifecycle, task lifecycle, and streamed output.

Types are derived from captured real CLI output (committed under test_cases/), captured via the credential-free --provider echo mode. Payload types not yet observed deserialize as MusePayload::Unknown rather than failing, and the envelope keeps the raw payload so round-trips are byte-faithful.

§Features

  • types — serde models only; wasm32-unknown-unknown compatible.
  • async-client (default) — Tokio client spawning muse exec --json.

§Quick start

use muse_codes::{ExecRun, MuseExecBuilder, MusePayload, Provider};

let run = ExecRun::spawn(
    &MuseExecBuilder::new("summarize this repo").provider(Provider::Meta),
).await?;

let terminal = run.wait_terminal(|record| {
    if let Ok(MusePayload::RunOutputDelta(d)) = record.typed_payload() {
        print!("{}", d.text);
    }
}).await?;
println!("\nterminal: {}", terminal.terminal);

Re-exports§

pub use error::Error;
pub use error::Result;
pub use io::CommandAccepted;
pub use io::Durability;
pub use io::MusePayload;
pub use io::MuseRecord;
pub use io::RecordType;
pub use io::RunOutputDelta;
pub use io::RunStarted;
pub use io::RunTerminal;
pub use io::SessionRunLinked;
pub use io::StreamKind;
pub use io::StreamRef;
pub use io::TaskLifecycle;
pub use io::TaskLifecycleEvent;
pub use io::TaskStreamLinked;
pub use io::TurnInputUser;
pub use cli::MuseExecBuilder;
pub use cli::Provider;
pub use client_async::ExecRun;

Modules§

cli
Builder for spawning headless muse exec --json runs.
client_async
Async client for streaming a headless muse exec --json run.
error
Error types for the muse-codes SDK.
io
Typed models of the muse exec --json JSONL event stream.
version
Version pins this crate is tested against.