muse-codes
Typed Rust SDK for Meta's Muse Code terminal coding agent.
Muse Code's headless mode (muse exec --json) emits an event-sourced JSONL
journal on stdout: envelope records covering command intake, run lifecycle,
task lifecycle, and streamed output. This crate types that stream and ships
an async Tokio client for driving headless runs.
Tested against Muse Code 0.1.0 (0.1.0-R708.1).
Captured, not guessed
Muse publishes no schema and no official SDK, so the wire is the contract:
- All models derive from committed captures of real CLI output
(
test_cases/*.jsonl), taken via the credential-free--provider echomode, which exercises the full headless event vocabulary without model calls or a Meta login. - The envelope keeps its payload as raw JSON (byte-faithful round-trips);
[
MuseRecord::typed_payload] lifts it into a typedMusePayload, and payload types not yet observed (the journal also records approvals, edits, and subagent lifecycle under a live provider) come back asMusePayload::Unknowninstead of failing. - A nightly workflow re-captures echo runs against the freshly installed
CLI, fingerprints
payload_type → field set, and files an issue on any drift from the committed snapshot (tests/schemas/muse_stream_fingerprint.txt).
Features
| Feature | Description | WASM-compatible |
|---|---|---|
types |
Journal envelope + payload models (serde only) | Yes |
async-client |
Tokio client spawning muse exec --json |
No |
default = ["types", "async-client"].
Quick start
use ;
let run = spawn.await?;
let terminal = run.wait_terminal.await?;
println!;
The Meta provider needs credentials (muse login, META_API_KEY, or
~/.config/muse/auth.json); Provider::Echo runs without any.
Testing
- Corpus tests: every committed capture line must parse, lift into a known typed payload, round-trip byte-faithfully, and satisfy envelope invariants (schema version, monotone sequences, durability classes).
- Live test (
--features integration-tests): drives a real echo-provider run through the typed client to its terminal record — needsmuseonPATH, no credentials.