@@ -595,7 +595,6 @@ async function startAgent(
595
595
const startAgents = async ( ) => {
596
596
const directClient = new DirectClient ( ) ;
597
597
const serverPort = parseInt ( settings . SERVER_PORT || "3000" ) ;
598
- directClient . start ( serverPort ) ;
599
598
const args = parseArguments ( ) ;
600
599
601
600
let charactersArg = args . characters || args . character ;
@@ -614,74 +613,13 @@ const startAgents = async () => {
614
613
elizaLogger . error ( "Error starting agents:" , error ) ;
615
614
}
616
615
617
- async function handleUserInput ( input , agentId ) {
618
- elizaLogger . log ( "handleUserInput" , input , agentId ) ;
619
- if ( input . toLowerCase ( ) === "exit" ) {
620
- gracefulExit ( ) ;
621
- }
622
-
623
- try {
624
- const serverPort = parseInt ( settings . SERVER_PORT || "3000" ) ;
625
-
626
- const response = await fetch (
627
- `http://localhost:${ serverPort } /${ agentId } /message` ,
628
- {
629
- method : "POST" ,
630
- headers : { "Content-Type" : "application/json" } ,
631
- body : JSON . stringify ( {
632
- text : input ,
633
- userId : "user" ,
634
- userName : "User" ,
635
- } ) ,
636
- }
637
- ) ;
638
-
639
- const data = await response . json ( ) ;
640
- elizaLogger . log ( "data: " , data ) ;
641
- data . forEach ( ( message ) =>
642
- elizaLogger . log ( `${ "Agent" } : ${ message . text } ` )
643
- ) ;
644
- } catch ( error ) {
645
- elizaLogger . error ( "Error fetching response:" , error ) ;
646
- }
647
- }
648
-
649
- function chat ( ) {
650
- elizaLogger . log ( "chat" ) ;
651
- const agentId = characters [ 0 ] . name ?? "Agent" ;
652
- elizaLogger . log ( "agentId: " , agentId ) ;
653
- rl . question ( "You: " , async ( input ) => {
654
- elizaLogger . log ( "input: " , input ) ;
655
- await handleUserInput ( input , agentId ) ;
656
- if ( input . toLowerCase ( ) !== "exit" ) {
657
- chat ( ) ; // Loop back to ask another question
658
- }
659
- } ) ;
660
- }
616
+ directClient . start ( serverPort ) ;
661
617
662
- if ( ! args [ "non-interactive" ] ) {
663
- elizaLogger . log ( "Chat started. Type 'exit' to quit." ) ;
664
- // log an empty line
665
- elizaLogger . log ( "" ) ;
666
- chat ( ) ;
667
- }
618
+ elizaLogger . log ( "Visit the following URL to chat with your agents:" ) ;
619
+ elizaLogger . log ( `http://localhost:5173` ) ;
668
620
} ;
669
621
670
622
startAgents ( ) . catch ( ( error ) => {
671
623
elizaLogger . error ( "Unhandled error in startAgents:" , error ) ;
672
624
process . exit ( 1 ) ; // Exit the process after logging
673
625
} ) ;
674
-
675
- const rl = readline . createInterface ( {
676
- input : process . stdin ,
677
- output : process . stdout ,
678
- } ) ;
679
-
680
- async function gracefulExit ( ) {
681
- elizaLogger . log ( "Terminating and cleaning up resources..." ) ;
682
- rl . close ( ) ;
683
- process . exit ( 0 ) ;
684
- }
685
-
686
- rl . on ( "SIGINT" , gracefulExit ) ;
687
- rl . on ( "SIGTERM" , gracefulExit ) ;
0 commit comments