|
16 | 16 |
|
17 | 17 | package com.google.adk.maven;
|
18 | 18 |
|
19 |
| -import com.google.adk.agents.BaseAgent; |
20 | 19 | import com.google.adk.maven.web.AdkWebServer;
|
21 | 20 | import java.io.IOException;
|
22 | 21 | import java.lang.reflect.Field;
|
|
25 | 24 | import java.net.URLClassLoader;
|
26 | 25 | import java.util.ArrayList;
|
27 | 26 | import java.util.List;
|
28 |
| -import java.util.Map; |
29 |
| -import java.util.concurrent.ConcurrentHashMap; |
30 | 27 | import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
31 | 28 | import org.apache.maven.plugin.AbstractMojo;
|
32 | 29 | import org.apache.maven.plugin.MojoExecutionException;
|
|
43 | 40 | /**
|
44 | 41 | * Maven plugin goal that starts the Google ADK Web Server with user-provided agents.
|
45 | 42 | *
|
46 |
| - * <p>This Mojo provides a convenient way for developers to test and interact with their Google ADK |
47 |
| - * agents through a web-based user interface. The plugin dynamically loads user-defined agents and |
48 |
| - * makes them available through a browser interface. |
| 43 | + * <p>This Mojo provides a convenient way for developers to test and interact with their agents |
| 44 | + * through ADK Web UI. The plugin dynamically loads user-defined agents and makes them available |
| 45 | + * through a browser interface. |
49 | 46 | *
|
50 | 47 | * <h3>Basic Usage</h3>
|
51 | 48 | *
|
52 | 49 | * <pre>{@code
|
53 |
| - * mvn google-adk:web -Dagents=com.example.MyAgentProvider.INSTANCE |
| 50 | + * mvn google-adk:web -Dagents=com.example.MyAgentProvider |
54 | 51 | * }</pre>
|
55 | 52 | *
|
56 | 53 | * <h3>Configuration Parameters</h3>
|
|
59 | 56 | * <li><strong>agents</strong> (required) - Full class path to AgentProvider implementation
|
60 | 57 | * <li><strong>port</strong> (optional, default: 8000) - Server port
|
61 | 58 | * <li><strong>host</strong> (optional, default: localhost) - Server host address
|
62 |
| - * <li><strong>hotReloading</strong> (optional, default: true) - Enable hot reloading |
| 59 | + * <li><strong>hotReloading</strong> (optional, default: true) - Enable hot reloading for |
| 60 | + * config-based agents |
63 | 61 | * </ul>
|
64 | 62 | *
|
65 | 63 | * <h3>AgentProvider Implementation</h3>
|
|
74 | 72 | *
|
75 | 73 | * <h3>Web Interface</h3>
|
76 | 74 | *
|
77 |
| - * <p>Once started, the web interface is available at {@code http://host:port} where users can |
78 |
| - * interact with available agents. |
| 75 | + * <p>Once started, ADK Web UI is available at {@code http://host:port} where users can interact |
| 76 | + * with available agents. |
79 | 77 | *
|
80 | 78 | * @author Google ADK Team
|
81 | 79 | * @since 0.2.1
|
@@ -103,7 +101,7 @@ public class WebMojo extends AbstractMojo {
|
103 | 101 | * <p>Example:
|
104 | 102 | *
|
105 | 103 | * <pre>{@code
|
106 |
| - * mvn google-adk:web -Dagents=com.example.MyAgentProvider.INSTANCE |
| 104 | + * mvn google-adk:web -Dagents=com.example.MyAgentProvider |
107 | 105 | * }</pre>
|
108 | 106 | */
|
109 | 107 | @Parameter(property = "agents")
|
@@ -168,37 +166,23 @@ public void execute() throws MojoExecutionException, MojoFailureException {
|
168 | 166 | getLog().info("Loading agent provider: " + agents);
|
169 | 167 | AgentProvider provider = loadAgentProvider();
|
170 | 168 |
|
171 |
| - getLog().info("Retrieving agents from provider..."); |
172 |
| - Map<String, BaseAgent> adkAgents = provider.getAgents(); |
173 |
| - |
174 |
| - if (adkAgents == null || adkAgents.isEmpty()) { |
175 |
| - throw new MojoExecutionException( |
176 |
| - "AgentProvider returned no agents. Please verify your provider implementation."); |
177 |
| - } |
178 |
| - |
179 |
| - getLog().info("Successfully loaded " + adkAgents.size() + " agents: " + adkAgents.keySet()); |
180 |
| - |
181 | 169 | // Set up system properties for Spring Boot
|
182 | 170 | setupSystemProperties();
|
183 | 171 |
|
184 |
| - // Create a registry that will be used by AdkWebServer |
185 |
| - Map<String, BaseAgent> agentRegistry = new ConcurrentHashMap<>(adkAgents); |
186 |
| - |
187 |
| - // Start the Spring Boot application with custom agent registry |
| 172 | + // Start the Spring Boot application with custom agent provider |
188 | 173 | SpringApplication app = new SpringApplication(AdkWebServer.class);
|
189 | 174 |
|
190 |
| - // Add the agent registry as a bean |
| 175 | + // Add the agent provider as a bean |
191 | 176 | app.addInitializers(
|
192 | 177 | ctx -> {
|
193 |
| - ctx.getBeanFactory().registerSingleton("userProvidedAgentRegistry", agentRegistry); |
| 178 | + ctx.getBeanFactory().registerSingleton("agentProvider", provider); |
194 | 179 | });
|
195 | 180 |
|
196 | 181 | getLog().info("Starting Spring Boot application...");
|
197 | 182 | applicationContext = app.run(new String[0]);
|
198 | 183 |
|
199 | 184 | getLog().info("🎉 ADK Web Server started successfully!");
|
200 | 185 | getLog().info("🌐 Web UI available at: http://" + host + ":" + port);
|
201 |
| - getLog().info("🛠️ Available agents: " + adkAgents.keySet()); |
202 | 186 | getLog().info("⏹️ Press Ctrl+C to stop the server...");
|
203 | 187 | getLog().info("");
|
204 | 188 |
|
@@ -361,7 +345,7 @@ private AgentProvider tryLoadFromConstructor() throws MojoExecutionException {
|
361 | 345 | }
|
362 | 346 | }
|
363 | 347 |
|
364 |
| - /** Cleans up all resources including application context, classloader, and executor service. */ |
| 348 | + /** Cleans up all resources including application context, classloader. */ |
365 | 349 | private void cleanupResources() {
|
366 | 350 | getLog().debug("Cleaning up resources...");
|
367 | 351 |
|
|
0 commit comments