From c98bdcff7d69d629c7b0e268c098e8f3bb9a48bb Mon Sep 17 00:00:00 2001 From: Seto Date: Fri, 9 Oct 2026 15:11:46 +0200 Subject: [PATCH] Add a library target so hosts can embed the agent src/lib.rs exposes the SplitFire profile (SplitFire, INFO, DEMUCS) and re-exports ed_acp, so an app can serve the agent in-process with ed_acp::serve instead of launching the binary. KaroKowe Jam does this to stay inside the App Store sandbox. The terminal UI and the MCP test stub move behind a default `cli` feature, and both binaries require it. A host builds with default-features = false and doesn't pull in ratatui and crossterm. Co-Authored-By: Claude Opus 5.5 --- Cargo.toml | 20 ++++++++++++++++++-- src/lib.rs | 15 +++++++++++++++ src/main.rs | 8 +------- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index f571d8e..d8fc2cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,11 +6,27 @@ license = "Apache-2.0" description = "Music-domain ACP agent: theory, production, industry, culture and live shows, backed by any OpenAI-compatible chat completions API" repository = "https://github.com/splitfireai/splitfire-agent" +[features] +default = ["cli"] +# The `splitfire-agent` binary: its terminal UI, plus the MCP stub the integration tests run. +# A host embedding the library turns this off. +cli = ["dep:ed-acp-tui", "ed-mcp/test-server"] + +[[bin]] +name = "splitfire-agent" +path = "src/main.rs" +required-features = ["cli"] + +[[bin]] +name = "mcp_stdio_stub" +path = "src/bin/mcp_stdio_stub.rs" +required-features = ["cli"] + [dependencies] # Onde Agent Platform: the ACP server, terminal UI and MCP layer, from the onde-ed workspace. ed-acp = { version = "1.1.0" } -ed-acp-tui = { version = "1.1.0" } -ed-mcp = { version = "1.1.0", features = ["test-server"] } +ed-acp-tui = { version = "1.1.0", optional = true } +ed-mcp = { version = "1.1.0" } agent-client-protocol = "2.2" anyhow = "1.0.104" async-trait = "0.1" diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..724f558 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,15 @@ +//! SplitFire as a library: the music agent's [`Profile`](ed_acp::Profile), for hosts that +//! embed it instead of launching the `splitfire-agent` binary. +//! +//! A host serves [`SplitFire`] with `ed_acp::serve` over an in-memory channel and runs an ACP +//! client on the other end, which keeps the agent inside an app sandbox that can't spawn it as +//! a subprocess. Build with `default-features = false` to leave out the terminal UI. + +mod audio; +pub mod profile; +mod prompt; +mod theory; +mod tools; + +pub use ed_acp; +pub use profile::{DEMUCS, INFO, SplitFire}; diff --git a/src/main.rs b/src/main.rs index 8f9655a..f85baa6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,12 +7,6 @@ //! it speaks ACP over stdio. Set ONDE_API_KEY (`app-id:app-secret`) or run `--setup`. //! SPLITFIRE_YOLO=1 skips permission prompts. Logs go to stderr (RUST_LOG). -mod audio; -mod profile; -mod prompt; -mod theory; -mod tools; - use std::io::IsTerminal; use std::path::PathBuf; use std::sync::Arc; @@ -20,7 +14,7 @@ use std::sync::Arc; use ed_acp::{LlmConfig, ServeOptions, cli}; use ed_acp_tui::TuiConfig; -use profile::{INFO, SplitFire}; +use splitfire_agent::{INFO, SplitFire}; const USAGE: &str = "\ Usage: splitfire-agent [--acp] [--yolo] [--list-models] [--root ...] [--setup] [--version]