Skip to content
Theme:

Embedding Wisp

Wisp can be embedded in other Rust applications. There are two entry points depending on how much control you need.

Cargo.toml
[dependencies]
wisp = "0.1"

The simplest way to embed Wisp. Pass an agent command string and Wisp handles everything: subprocess spawning, ACP handshake, session creation, and the TUI event loop.

use wisp::run_tui;
#[tokio::main]
async fn main() -> Result<(), wisp::AppError> {
wisp::setup_logging(None);
run_tui("my-agent serve").await
}

The command string is split and executed as a subprocess. The agent must speak ACP over stdin/stdout.

For more control, initialize RuntimeState yourself and pass it in:

use wisp::{run_with_state, RuntimeState};
let state = RuntimeState {
session_id,
agent_name: "my-agent".into(),
prompt_capabilities,
config_options: vec![],
auth_methods: vec![],
theme,
event_rx,
prompt_handle,
working_dir: std::env::current_dir()?,
};
run_with_state(state).await?;

This is useful when you want to:

  • Pre-configure the ACP connection
  • Use a custom transport (not stdin/stdout subprocess)
  • Set up logging or error handling differently
  • Run initialization logic before the TUI starts
FieldTypeDescription
session_idSessionIdActive session identifier
agent_nameStringAgent’s display name (shown in status line)
prompt_capabilitiesPromptCapabilitiesPrompt capabilities advertised by the agent
config_optionsVec<SessionConfigOption>Agent-advertised settings
auth_methodsVec<AuthMethod>Available authentication methods
themeThemeUI color theme
event_rxUnboundedReceiver<AcpEvent>Channel receiving events from agent
prompt_handleAcpPromptHandleHandle for sending prompts and commands
working_dirPathBufWorking directory for file operations