Repository: google/adk-go
File: cmd/launcher/web/a2a/a2a.go (Go)

Code before:

	return &a2aLauncher{
		config: config,
		flags:  fs,
	}
}

func (a *a2aLauncher) CommandLineSyntax() string {
	return util.FormatFlagUsage(a.flags)
}

func (a *a2aLauncher) Keyword() string {
	return "a2a"
}

func (a *a2aLauncher) Parse(args []string) ([]string, error) {
	err := a.flags.Parse(args)
	if err != nil || !a.flags.Parsed() {
		return nil, fmt.Errorf("failed to parse a2a flags: %v", err)
	}
	restArgs := a.flags.Args()
	return restArgs, nil
}

// WrapHandlers implements web.WebSublauncher. For API, it doesn't change the top-level routes.
func (a *a2aLauncher) WrapHandlers(handler http.Handler, adkConfig *adk.Config) http.Handler {
	// doesn't change the top level routes
	return handler
}

// SimpleDescription implements web.WebSublauncher. For A2A no subrouter definition is needed
func (a *a2aLauncher) SetupSubrouters(router *mux.Router, adkConfig *adk.Config) error {
	publicURL, err := url.JoinPath(a.config.agentURL, apiPath)
	if err != nil {
		return err
	}

	rootAgent := adkConfig.AgentLoader.RootAgent()
	agentCard := &a2acore.AgentCard{
		Name:                              rootAgent.Name(),
		Description:                       rootAgent.Description(),
		DefaultInputModes:                 []string{"text/plain"},
		DefaultOutputModes:                []string{"text/plain"},
		URL:                               publicURL,
		PreferredTransport:                a2acore.TransportProtocolJSONRPC,
		Skills:                            adka2a.BuildAgentSkills(rootAgent),
		Capabilities:                      a2acore.AgentCapabilities{Streaming: true},
		SupportsAuthenticatedExtendedCard: false,
	}
	router.Handle(a2asrv.WellKnownAgentCardPath, a2asrv.NewStaticAgentCardHandler(agentCard))


Review comment (suggestion):
It WrapHandler is not needed anymore, please remove it completely. It was needed only for the sake of a2a

Code after:
	return &a2aLauncher{
		config: config,
		flags:  fs,
	}
}

func (a *a2aLauncher) CommandLineSyntax() string {
	return util.FormatFlagUsage(a.flags)
}

func (a *a2aLauncher) Keyword() string {
	return "a2a"
}

func (a *a2aLauncher) Parse(args []string) ([]string, error) {
	err := a.flags.Parse(args)
	if err != nil || !a.flags.Parsed() {
		return nil, fmt.Errorf("failed to parse a2a flags: %v", err)
	}
	restArgs := a.flags.Args()
	return restArgs, nil
}

// SetupSubrouters implements the web.WebSublauncher interface. It adds A2A paths to the main router.
func (a *a2aLauncher) SetupSubrouters(router *mux.Router, adkConfig *adk.Config) error {
	publicURL, err := url.JoinPath(a.config.agentURL, apiPath)
	if err != nil {
		return err
	}

	rootAgent := adkConfig.AgentLoader.RootAgent()
	agentCard := &a2acore.AgentCard{
		Name:                              rootAgent.Name(),
		Description:                       rootAgent.Description(),
		DefaultInputModes:                 []string{"text/plain"},
		DefaultOutputModes:                []string{"text/plain"},
		URL:                               publicURL,
		PreferredTransport:                a2acore.TransportProtocolJSONRPC,
		Skills:                            adka2a.BuildAgentSkills(rootAgent),
		Capabilities:                      a2acore.AgentCapabilities{Streaming: true},
		SupportsAuthenticatedExtendedCard: false,
	}
	router.Handle(a2asrv.WellKnownAgentCardPath, a2asrv.NewStaticAgentCardHandler(agentCard))

	agent := adkConfig.AgentLoader.RootAgent()
	executor := adka2a.NewExecutor(adka2a.ExecutorConfig{
		RunnerConfig: runner.Config{
			AppName:         agent.Name(),
			Agent:           agent,
			SessionService:  adkConfig.SessionService,
			ArtifactService: adkConfig.ArtifactService,