@@ -437,11 +437,66 @@ fn show_help(siv: &mut Cursive) {
437437pub async fn run_agent_chat ( ) -> Result < ( ) > {
438438 println ! ( "🚀 Starting OSVM Agent Chat Interface..." ) ;
439439
440+ // Check if we're in a terminal environment
441+ if std:: env:: var ( "TERM" ) . is_err ( ) || std:: env:: var ( "CI" ) . is_ok ( ) {
442+ return run_demo_mode ( ) . await ;
443+ }
444+
440445 let mut chat_ui = AgentChatUI :: new ( )
441446 . context ( "Failed to initialize chat UI" ) ?;
442447
443448 chat_ui. run ( ) . await
444449 . context ( "Failed to run chat interface" ) ?;
445450
451+ Ok ( ( ) )
452+ }
453+
454+ /// Run demo mode for non-terminal environments
455+ async fn run_demo_mode ( ) -> Result < ( ) > {
456+ println ! ( "📱 Running in demo mode (terminal UI not available)" ) ;
457+ println ! ( ) ;
458+
459+ // Initialize chat state to show MCP integration
460+ let state = ChatState :: new ( ) ?;
461+ state. refresh_tools_sync ( ) ?;
462+
463+ // Show what the interface provides
464+ println ! ( "🎯 OSVM Agent Chat Interface Features:" ) ;
465+ println ! ( " • Interactive chat interface using cursive-multiplex" ) ;
466+ println ! ( " • Integration with configured MCP servers" ) ;
467+ println ! ( " • Real-time tool calling and blockchain operations" ) ;
468+ println ! ( " • Multi-panel layout with chat history and tool status" ) ;
469+ println ! ( ) ;
470+
471+ // Show MCP server status
472+ let tools = state. available_tools . lock ( ) . unwrap ( ) ;
473+ if tools. is_empty ( ) {
474+ println ! ( "⚠️ No MCP servers configured." ) ;
475+ println ! ( " Use 'osvm mcp setup' to configure Solana MCP server" ) ;
476+ println ! ( " or 'osvm mcp add <server_id> --server-url <url>' to add custom servers" ) ;
477+ } else {
478+ println ! ( "🔌 Configured MCP Servers:" ) ;
479+ for ( server_id, server_tools) in tools. iter ( ) {
480+ println ! ( " • {}: Available (tools would be fetched in interactive mode)" , server_id) ;
481+ }
482+ }
483+
484+ println ! ( ) ;
485+ println ! ( "💡 Sample Chat Interaction:" ) ;
486+ println ! ( " User: What's the balance of my Solana wallet?" ) ;
487+ println ! ( " Agent: I'll check your wallet balance using the Solana MCP tools..." ) ;
488+ println ! ( " Agent: [Calls solana_get_balance tool with your wallet address]" ) ;
489+ println ! ( " Agent: Your wallet balance is 2.5 SOL" ) ;
490+ println ! ( ) ;
491+
492+ println ! ( " User: Show me recent transactions" ) ;
493+ println ! ( " Agent: [Calls solana_get_signatures tool]" ) ;
494+ println ! ( " Agent: Here are your recent transactions: [transaction list]" ) ;
495+ println ! ( ) ;
496+
497+ println ! ( "💻 To use the full interactive interface:" ) ;
498+ println ! ( " Run 'osvm chat' in a proper terminal environment" ) ;
499+ println ! ( ) ;
500+
446501 Ok ( ( ) )
447502}
0 commit comments