PromptOAuthAuthorization prompts the user for OAuth authorization
(ctx context.Context, serverURL string)
| 178 | |
| 179 | // PromptOAuthAuthorization prompts the user for OAuth authorization |
| 180 | func (p *Printer) PromptOAuthAuthorization(ctx context.Context, serverURL string) ConfirmationResult { |
| 181 | p.Println("\n🔐 OAuth Authorization Required") |
| 182 | p.Println("Server:", serverURL, "(remote)") |
| 183 | p.Println("This server requires OAuth authentication to access its tools.") |
| 184 | p.Println("Your browser will open automatically to complete the authorization.") |
| 185 | p.Printf("\n%s (y/n): ", "Do you want to authorize access?") |
| 186 | |
| 187 | response, err := input.ReadLine(ctx, os.Stdin) |
| 188 | if err != nil { |
| 189 | p.Println("\nFailed to read input, aborting authorization...") |
| 190 | return ConfirmationAbort |
| 191 | } |
| 192 | |
| 193 | response = strings.TrimSpace(strings.ToLower(response)) |
| 194 | if response == "y" || response == "yes" { |
| 195 | p.Println("✓ Starting OAuth authorization...") |
| 196 | p.Println("Please complete the authorization in your browser.") |
| 197 | p.Print("Once completed, the agent will continue automatically.\n\n") |
| 198 | return ConfirmationApprove |
| 199 | } else { |
| 200 | p.Print("Authorization declined. Exiting...\n\n") |
| 201 | return ConfirmationReject |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | func formatToolCallArguments(arguments string) string { |
| 206 | if arguments == "" { |