(ctx context.Context, agentFilename, agentName, sessionDB string, runConfig *config.RuntimeConfig, ln net.Listener)
| 41 | } |
| 42 | |
| 43 | func Run(ctx context.Context, agentFilename, agentName, sessionDB string, runConfig *config.RuntimeConfig, ln net.Listener) error { |
| 44 | slog.DebugContext(ctx, "Starting A2A server", "source", agentFilename, "agent", agentName, "addr", ln.Addr().String()) |
| 45 | |
| 46 | agentSource, err := config.Resolve(agentFilename, nil) |
| 47 | if err != nil { |
| 48 | return err |
| 49 | } |
| 50 | |
| 51 | t, err := teamloader.Load(ctx, agentSource, runConfig, loaderdefaults.Opts()...) |
| 52 | if err != nil { |
| 53 | return fmt.Errorf("failed to load agents: %w", err) |
| 54 | } |
| 55 | defer func() { |
| 56 | if err := t.StopToolSets(ctx); err != nil { |
| 57 | slog.ErrorContext(ctx, "Failed to stop tool sets", "error", err) |
| 58 | } |
| 59 | }() |
| 60 | |
| 61 | expandedSessionDB, err := pathx.ExpandHomeDir(sessionDB) |
| 62 | if err != nil { |
| 63 | return fmt.Errorf("failed to expand session db path: %w", err) |
| 64 | } |
| 65 | sessStore, err := session.NewSQLiteSessionStore(ctx, expandedSessionDB) |
| 66 | if err != nil { |
| 67 | return fmt.Errorf("failed to open session store: %w", err) |
| 68 | } |
| 69 | |
| 70 | adkAgent, err := newDockerAgentAdapter(t, agentName, sessStore) |
| 71 | if err != nil { |
| 72 | return fmt.Errorf("failed to create ADK agent adapter: %w", err) |
| 73 | } |
| 74 | |
| 75 | baseURL := &url.URL{Scheme: "http", Host: routableAddr(ln.Addr().String())} |
| 76 | |
| 77 | slog.DebugContext(ctx, "A2A server listening", "url", baseURL.String()) |
| 78 | |
| 79 | name := strings.TrimSuffix(filepath.Base(agentFilename), filepath.Ext(agentFilename)) |
| 80 | |
| 81 | agentPath := "/invoke" |
| 82 | agentCard := &a2a.AgentCard{ |
| 83 | Name: name, |
| 84 | Description: adkAgent.Description(), |
| 85 | Skills: []a2a.AgentSkill{{ |
| 86 | ID: fmt.Sprintf("%s_%s", name, agentName), |
| 87 | Name: agentName, |
| 88 | Description: adkAgent.Description(), |
| 89 | Tags: []string{"llm", "docker agent"}, |
| 90 | }}, |
| 91 | PreferredTransport: a2a.TransportProtocolJSONRPC, |
| 92 | URL: baseURL.JoinPath(agentPath).String(), |
| 93 | Capabilities: a2a.AgentCapabilities{Streaming: true}, |
| 94 | Version: version.Version, |
| 95 | DefaultInputModes: []string{}, |
| 96 | DefaultOutputModes: []string{}, |
| 97 | } |
| 98 | |
| 99 | executor := newExecutorWrapper(adka2a.ExecutorConfig{ |
| 100 | RunnerConfig: runner.Config{ |
no test coverage detected