11#!/usr/bin/env python3
2- """
3- Simple main entry point for OpenHands CLI.
4- This is a simplified version that demonstrates the TUI functionality.
5- """
2+ """Simple main entry point for OpenHands CLI."""
63
74import logging
85import os
9- import sys
106import warnings
117
12- debug_env = os .getenv ('DEBUG' , 'false' ).lower ()
13- if debug_env != '1' and debug_env != 'true' :
14- logging .disable (logging .WARNING )
15- warnings .filterwarnings ('ignore' )
16-
178from prompt_toolkit import print_formatted_text
189from prompt_toolkit .formatted_text import HTML
1910
2011from openhands_cli .argparsers .main_parser import create_main_parser
12+ from openhands_cli .utils import create_seeded_instructions_from_args
13+
14+
15+ debug_env = os .getenv ("DEBUG" , "false" ).lower ()
16+ if debug_env != "1" and debug_env != "true" :
17+ logging .disable (logging .WARNING )
18+ warnings .filterwarnings ("ignore" )
2119
2220
2321def main () -> None :
@@ -31,54 +29,40 @@ def main() -> None:
3129 args = parser .parse_args ()
3230
3331 try :
34- if args .command == ' serve' :
32+ if args .command == " serve" :
3533 # Import gui_launcher only when needed
3634 from openhands_cli .gui_launcher import launch_gui_server
3735
3836 launch_gui_server (mount_cwd = args .mount_cwd , gpu = args .gpu )
37+ elif args .command == "acp" :
38+ import asyncio
39+
40+ from openhands_cli .acp_impl .agent import run_acp_server
41+
42+ asyncio .run (run_acp_server ())
3943 else :
4044 # Default CLI behavior - no subcommand needed
4145 # Import agent_chat only when needed
4246 from openhands_cli .agent_chat import run_cli_entry
4347
44- # Build queued inputs from task and file arguments
45- queued_inputs = []
46- if args .task :
47- queued_inputs .append (args .task )
48- if args .file :
49- try :
50- with open (args .file , 'r' , encoding = 'utf-8' ) as f :
51- file_content = f .read ()
52- queued_inputs .append (file_content )
53- except FileNotFoundError :
54- print_formatted_text (
55- HTML (f'<red>Error: File not found: { args .file } </red>' )
56- )
57- return
58- except Exception as e :
59- print_formatted_text (
60- HTML (f'<red>Error reading file: { e } </red>' )
61- )
62- return
48+ queued_inputs = create_seeded_instructions_from_args (args )
6349
6450 # Start agent chat
65- # Keep call signature backward-compatible for upstream tests
6651 run_cli_entry (
6752 resume_conversation_id = args .resume ,
68- queued_inputs = queued_inputs if queued_inputs else None ,
69- user_skills = args .user_skills ,
70- project_skills = getattr (args , 'project_skills' , True ),
53+ queued_inputs = queued_inputs ,
7154 )
7255 except KeyboardInterrupt :
73- print_formatted_text (HTML (' \n <yellow>Goodbye! π</yellow>' ))
56+ print_formatted_text (HTML (" \n <yellow>Goodbye! π</yellow>" ))
7457 except EOFError :
75- print_formatted_text (HTML (' \n <yellow>Goodbye! π</yellow>' ))
58+ print_formatted_text (HTML (" \n <yellow>Goodbye! π</yellow>" ))
7659 except Exception as e :
77- print_formatted_text (HTML (f' <red>Error: { e } </red>' ))
60+ print_formatted_text (HTML (f" <red>Error: { e } </red>" ))
7861 import traceback
7962
8063 traceback .print_exc ()
8164 raise
8265
83- if __name__ == '__main__' :
84- main ()
66+
67+ if __name__ == "__main__" :
68+ main ()
0 commit comments