prod.go
Overview
The prod.go file provides an entry point for launching a universal launcher in a production environment that integrates the Agent Development Kit (ADK) with available functionalities. It enables running the ADK without the need for development-supporting components such as consoles or web-based user interfaces. This launcher supports interaction solely through the API and Agent-to-Agent (A2A) communication protocols, facilitating headless or backend-only deployments.
The primary purpose of this file is to construct and expose a fully configured launcher instance that combines REST API serving and A2A communication, encapsulated within a universal launcher framework.
Package and Imports
Package:
prod
This package provides a simplified way to run the ADK with all core options activated but excludes any UI or console support, focusing on API and A2A interfaces.Imports:
launcher(fromgoogle.golang.org/adk/cmd/launcher): Defines the coreLauncherinterface.universal(from google.golang.org/adk/cmd/launcher/universal): Provides a universal launcher implementation that can combine multiple launchers.web(from google.golang.org/adk/cmd/launcher/web): Implements a web-based launcher framework.a2a(from google.golang.org/adk/cmd/launcher/web/a2a): Implements the Agent-to-Agent communication launcher.api(from google.golang.org/adk/cmd/launcher/web/api): Implements the REST API launcher.
Key Function
NewLauncher() launcher.Launcher
func NewLauncher() launcher.Launcher
Description:
Constructs and returns a configured universal launcher that combines the REST API launcher and the A2A launcher within a web launcher, all wrapped inside a universal launcher.Returns:
launcher.Launcher: An instance of the universal launcher capable of serving both API and A2A endpoints.
Implementation Details:
The function calls theNewLauncherfunctions of the sub-launchers in a nested manner:api.NewLauncher(): Creates a launcher for the REST API interface.a2a.NewLauncher(): Creates a launcher for the A2A communication protocol.web.NewLauncher(apiLauncher, a2aLauncher): Combines the API and A2A launchers under a single web launcher.universal.NewLauncher(webLauncher): Wraps the web launcher inside a universal launcher that can be used as a single launcher interface.
Usage Example:
import "google.golang.org/adk/cmd/launcher/prod"
func main() {
launcher := prod.NewLauncher()
launcher.Run() // Hypothetical method to start the launcher
}
Important Implementation Notes
This file does not implement any new algorithms or complex logic; it is mainly a composition module that ties together existing launcher components.
The
universal.Launcheracts as a container allowing multiple launcher implementations to be served seamlessly.The
web.Launcherhosts sub-launchers for the API and A2A protocols, providing HTTP endpoints for external communication.By excluding console or web UI launchers, this setup is optimized for environments where interaction is done programmatically or remotely via APIs.
Interaction with Other System Components
API Launcher (
api): Handles RESTful HTTP requests to interact with agents, sessions, artifacts, and other ADK services. See REST API and Web Launchers for detailed information.A2A Launcher (
a2a): Supports distributed agent communication using the Agent-To-Agent protocol described in Remote Agent Communication (A2A).Universal Launcher (
universal): Facilitates combining multiple launchers into one unified interface, enabling simultaneous serving of API and A2A without conflict.Web Launcher (
web): Provides the HTTP server infrastructure hosting the API and A2A sub-launchers. Refer to Web Server Launcher and API and A2A Sublaunchers for further details.
This modular design allows the prod package to bootstrap a production-ready ADK deployment that supports external API calls and A2A agent messaging without additional UI layers.
Diagram: Launcher Composition Structure
classDiagram
class prod {
+NewLauncher()
}
class universalLauncher {
+Run()
}
class webLauncher {
+Run()
}
class apiLauncher {
+Run()
}
class a2aLauncher {
+Run()
}
prod --> universalLauncher : returns
universalLauncher --> webLauncher : wraps
webLauncher --> apiLauncher : contains
webLauncher --> a2aLauncher : contains
This diagram illustrates the hierarchical composition of the launcher components:
The
prodpackage exposesNewLauncher()which returns auniversalLauncher.The
universalLauncherwraps awebLauncher.The
webLaunchercontains two sub-launchers:apiLauncheranda2aLauncher.Each launcher exposes a
Run()method (implied) to start serving its respective interface.
For additional context on the launcher implementations and their interactions, see the topics:
[Universal Launcher Pattern](not explicitly in provided topics but related to launcher composition)