77
88 "github.com/spf13/cobra"
99
10+ "github.com/docker/cagent/pkg/cli"
1011 "github.com/docker/cagent/pkg/creator"
1112 "github.com/docker/cagent/pkg/input"
1213 "github.com/docker/cagent/pkg/runtime"
@@ -54,19 +55,19 @@ func NewNewCmd() *cobra.Command {
5455 switch {
5556 case os .Getenv ("ANTHROPIC_API_KEY" ) != "" :
5657 modelProvider = "anthropic"
57- fmt .Printf ("%s\n \n " , white ("ANTHROPIC_API_KEY found, using Anthropic" ))
58+ fmt .Printf ("%s\n \n " , cli . White ("ANTHROPIC_API_KEY found, using Anthropic" ))
5859 case os .Getenv ("OPENAI_API_KEY" ) != "" :
5960 modelProvider = "openai"
60- fmt .Printf ("%s\n \n " , white ("OPENAI_API_KEY found, using OpenAI" ))
61+ fmt .Printf ("%s\n \n " , cli . White ("OPENAI_API_KEY found, using OpenAI" ))
6162 case os .Getenv ("GOOGLE_API_KEY" ) != "" :
6263 modelProvider = "google"
63- fmt .Printf ("%s\n \n " , white ("GOOGLE_API_KEY found, using Google" ))
64+ fmt .Printf ("%s\n \n " , cli . White ("GOOGLE_API_KEY found, using Google" ))
6465 default :
6566 modelProvider = "dmr"
66- fmt .Printf ("%s\n \n " , yellow ("⚠️ No provider credentials found, defaulting to Docker Model Runner (DMR)" ))
67+ fmt .Printf ("%s\n \n " , cli . Yellow ("⚠️ No provider credentials found, defaulting to Docker Model Runner (DMR)" ))
6768 }
6869 if modelParam == "" {
69- fmt .Printf ("%s\n \n " , white ("use \" --model provider/model\" to use a different model" ))
70+ fmt .Printf ("%s\n \n " , cli . White ("use \" --model provider/model\" to use a different model" ))
7071 }
7172 } else {
7273 // Using Models Gateway; default to Anthropic if not specified
@@ -78,10 +79,10 @@ func NewNewCmd() *cobra.Command {
7879 if len (args ) > 0 {
7980 prompt = strings .Join (args , " " )
8081 } else {
81- fmt .Printf ("%s\n " , blue ("------- Welcome to %s! -------" , bold (AppName )))
82- fmt .Printf ("%s\n \n " , white (" (Ctrl+C to exit)" ))
83- fmt .Printf ("%s\n \n " , blue ("What should your agent/agent team do? (describe its purpose)" ))
84- fmt .Print (blue ("> " ))
82+ fmt .Printf ("%s\n " , cli . Blue ("------- Welcome to %s! -------" , cli . Bold (AppName )))
83+ fmt .Printf ("%s\n \n " , cli . White (" (Ctrl+C to exit)" ))
84+ fmt .Printf ("%s\n \n " , cli . Blue ("What should your agent/agent team do? (describe its purpose)" ))
85+ fmt .Print (cli . Blue ("> " ))
8586
8687 var err error
8788 prompt , err = input .ReadLine (ctx , os .Stdin )
@@ -112,33 +113,33 @@ func NewNewCmd() *cobra.Command {
112113 fmt .Println ()
113114 llmIsTyping = false
114115 }
115- printToolCall (e .ToolCall )
116+ cli . PrintToolCall (e .ToolCall )
116117 case * runtime.ToolCallResponseEvent :
117118 if llmIsTyping {
118119 fmt .Println ()
119120 llmIsTyping = false
120121 }
121- printToolCallResponse (e .ToolCall , e .Response )
122+ cli . PrintToolCallResponse (e .ToolCall , e .Response )
122123 case * runtime.ErrorEvent :
123124 if llmIsTyping {
124125 fmt .Println ()
125126 llmIsTyping = false
126127 }
127- printError (fmt .Errorf ("%s" , e .Error ))
128+ cli . PrintError (fmt .Errorf ("%s" , e .Error ))
128129 case * runtime.MaxIterationsReachedEvent :
129130 if llmIsTyping {
130131 fmt .Println ()
131132 llmIsTyping = false
132133 }
133134
134- result := promptMaxIterationsContinue (ctx , e .MaxIterations )
135+ result := cli . PromptMaxIterationsContinue (ctx , e .MaxIterations )
135136 switch result {
136- case ConfirmationApprove :
137+ case cli . ConfirmationApprove :
137138 rt .Resume (ctx , string (runtime .ResumeTypeApprove ))
138- case ConfirmationReject :
139+ case cli . ConfirmationReject :
139140 rt .Resume (ctx , string (runtime .ResumeTypeReject ))
140141 return nil
141- case ConfirmationAbort :
142+ case cli . ConfirmationAbort :
142143 rt .Resume (ctx , string (runtime .ResumeTypeReject ))
143144 }
144145 }
0 commit comments