Expand description
Agent Core TUI
TUI frontend for agent-core, providing a ratatui-based terminal interface.
This crate provides:
- TuiRunner - Extension to run AgentCore with a TUI
- App - Complete TUI application with chat, input, and command handling
- ChatView - Chat message display with streaming support
- Layout system - Flexible layout system with templates and custom layouts
- Permission and question panels for tool interactions
- Markdown rendering with theming support
- Table rendering
- Session pickers
- Slash command system
- Text input with cursor management
- Theme system with 45+ built-in themes
§Quick Start
ⓘ
use agent_core_runtime::agent::{AgentConfig, AgentCore};
use agent_core_tui::AgentCoreExt;
struct MyConfig;
impl AgentConfig for MyConfig {
fn config_path(&self) -> &str { ".myagent/config.yaml" }
fn default_system_prompt(&self) -> &str { "You are helpful." }
fn log_prefix(&self) -> &str { "myagent" }
fn name(&self) -> &str { "MyAgent" }
}
fn main() -> std::io::Result<()> {
let agent = AgentCore::new(&MyConfig)?;
agent.into_tui().run()
}Re-exports§
pub use commands::ClearCommand;pub use commands::CommandContext;pub use commands::CommandRegistry;pub use commands::CommandResult;pub use commands::CompactCommand;pub use commands::CustomCommand;pub use commands::HelpCommand;pub use commands::NewSessionCommand;pub use commands::QuitCommand;pub use commands::SessionsCommand;pub use commands::SlashCommand;pub use commands::StatusCommand;pub use commands::ThemesCommand;pub use commands::VersionCommand;pub use commands::default_commands;pub use commands::filter_commands;pub use commands::generate_help_message;pub use commands::get_command_by_name;pub use commands::is_slash_command;pub use commands::parse_command;pub use markdown::ContentSegment;pub use markdown::parse_to_spans;pub use markdown::parse_to_styled_words;pub use markdown::render_markdown_with_prefix;pub use markdown::split_content_segments;pub use markdown::wrap_with_prefix;pub use table::PulldownRenderer;pub use table::TableRenderer;pub use table::is_table_line;pub use table::is_table_separator;pub use table::render_table;pub use widgets::AnswerState;pub use widgets::BatchPermissionPanel;pub use widgets::ChatView;pub use widgets::ConversationView;pub use widgets::ConversationViewFactory;pub use widgets::EnterAction;pub use widgets::FocusItem;pub use widgets::MessageRole;pub use widgets::PermissionKeyAction;pub use widgets::PermissionOption;pub use widgets::PermissionPanel;pub use widgets::QuestionKeyAction;pub use widgets::QuestionPanel;pub use widgets::RenderFn;pub use widgets::SessionInfo;pub use widgets::SessionPickerState;pub use widgets::SimpleCommand;pub use widgets::SlashCommandDisplay;pub use widgets::SlashPopupState;pub use widgets::StatusBar;pub use widgets::StatusBarConfig;pub use widgets::StatusBarData;pub use widgets::TextInput;pub use widgets::ToolMessageData;pub use widgets::ToolStatus;pub use widgets::render_session_picker;pub use widgets::render_slash_popup;pub use themes::THEMES;pub use themes::Theme;pub use themes::ThemeInfo;pub use themes::ThemePickerState;pub use themes::current_theme_name;pub use themes::default_theme_name;pub use themes::get_theme;pub use themes::init_theme;pub use themes::list_themes;pub use themes::render_theme_picker;pub use themes::set_theme;pub use themes::theme as app_theme;pub use themes::theme as app_theme;pub use layout::LayoutContext;pub use layout::LayoutProvider;pub use layout::LayoutResult;pub use layout::LayoutTemplate;pub use layout::MinimalOptions;pub use layout::SidebarOptions;pub use layout::SidebarPosition;pub use layout::SidebarWidth;pub use layout::SplitOptions;pub use layout::SplitRatio;pub use layout::StandardOptions;pub use layout::WidgetSizes;pub use layout::helpers as layout_helpers;pub use keys::AppKeyAction;pub use keys::AppKeyResult;pub use keys::DefaultKeyHandler;pub use keys::ExitHandler;pub use keys::ExitState;pub use keys::KeyBindings;pub use keys::KeyCombo;pub use keys::KeyContext;pub use keys::KeyHandler;
Modules§
- agent
- Agent infrastructure and configuration. Agent Infrastructure
- client
- LLM client interface and provider implementations. LLM client with provider-agnostic interface.
- commands
- Slash command system. Slash command system for the TUI.
- controller
- LLM session controller and tool execution. LLM session controller and tool execution framework.
- keys
- Key handling and bindings. Customizable key handling for LLM TUI applications.
- layout
- Layout templates and providers. Layout system for TUI widgets
- markdown
- Markdown rendering utilities. Markdown parsing utilities for TUI rendering
- permissions
- Permission system for controlling agent access to resources. Permission system for controlling agent access to resources.
- table
- Table rendering utilities. Table rendering utilities for TUI
- themes
- Theme system and built-in themes. Application-level TUI components
- widgets
- TUI widgets (chat, input, panels). TUI Widgets
Macros§
- define_
theme - Macro to define a theme from a color palette.
Generates the
pub fn theme() -> Themefunction. - register_
themes - Macro to register all themes with their metadata. Generates mod declarations, THEMES array, and get_theme function.
Structs§
- App
- Terminal UI application with chat, input, and command handling.
- AppConfig
- Configuration for the App
- TuiRunner
- TUI configuration that extends AgentCore with TUI-specific settings.
Traits§
- Agent
Core Ext - Extension trait to add TUI functionality to AgentCore.