Documentation
¶
Index ¶
- Variables
- func GenerateTaskID() string
- func JSONTool(result interface{}) (string, error)
- func NewEmptyMessagePartsError() error
- func NewStreamingNotImplementedError() error
- func NewTaskNotFoundError(taskID string) error
- func StringPtr(s string) *string
- type A2AServer
- func CustomA2AServer(cfg config.Config, logger *zap.Logger, taskHandler TaskHandler, ...) (A2AServer, error)
- func CustomA2AServerWithAgent(cfg config.Config, logger *zap.Logger, agent OpenAICompatibleAgent, ...) (A2AServer, error)
- func SimpleA2AServerWithAgent(cfg config.Config, logger *zap.Logger, agent OpenAICompatibleAgent, ...) (A2AServer, error)
- type A2AServerBuilder
- type A2AServerBuilderImpl
- func (b *A2AServerBuilderImpl) Build() (A2AServer, error)
- func (b *A2AServerBuilderImpl) WithAgent(agent OpenAICompatibleAgent) A2AServerBuilder
- func (b *A2AServerBuilderImpl) WithAgentCard(agentCard types.AgentCard) A2AServerBuilder
- func (b *A2AServerBuilderImpl) WithAgentCardFromFile(filePath string, overrides map[string]interface{}) A2AServerBuilder
- func (b *A2AServerBuilderImpl) WithLogger(logger *zap.Logger) A2AServerBuilder
- func (b *A2AServerBuilderImpl) WithTaskHandler(handler TaskHandler) A2AServerBuilder
- func (b *A2AServerBuilderImpl) WithTaskResultProcessor(processor TaskResultProcessor) A2AServerBuilder
- type A2AServerImpl
- func NewA2AServer(cfg *config.Config, logger *zap.Logger, otel otel.OpenTelemetry) *A2AServerImpl
- func NewA2AServerEnvironmentAware(cfg *config.Config, logger *zap.Logger, otel otel.OpenTelemetry) *A2AServerImpl
- func NewA2AServerWithAgent(cfg *config.Config, logger *zap.Logger, otel otel.OpenTelemetry, ...) *A2AServerImpl
- func NewDefaultA2AServer(cfg *config.Config) *A2AServerImpl
- func (s *A2AServerImpl) GetAgent() OpenAICompatibleAgent
- func (s *A2AServerImpl) GetAgentCard() *types.AgentCard
- func (s *A2AServerImpl) GetTaskHandler() TaskHandler
- func (s *A2AServerImpl) LoadAgentCardFromFile(filePath string, overrides map[string]interface{}) error
- func (s *A2AServerImpl) ProcessTask(ctx context.Context, task *types.Task, message *types.Message) (*types.Task, error)
- func (s *A2AServerImpl) SetAgent(agent OpenAICompatibleAgent)
- func (s *A2AServerImpl) SetAgentCard(agentCard types.AgentCard)
- func (s *A2AServerImpl) SetAgentDescription(description string)
- func (s *A2AServerImpl) SetAgentName(name string)
- func (s *A2AServerImpl) SetAgentURL(url string)
- func (s *A2AServerImpl) SetAgentVersion(version string)
- func (s *A2AServerImpl) SetTaskHandler(handler TaskHandler)
- func (s *A2AServerImpl) SetTaskResultProcessor(processor TaskResultProcessor)
- func (s *A2AServerImpl) Start(ctx context.Context) error
- func (s *A2AServerImpl) StartTaskProcessor(ctx context.Context)
- func (s *A2AServerImpl) Stop(ctx context.Context) error
- type AgentBuilder
- type AgentBuilderImpl
- func (b *AgentBuilderImpl) Build() (*DefaultOpenAICompatibleAgent, error)
- func (b *AgentBuilderImpl) GetConfig() *config.AgentConfig
- func (b *AgentBuilderImpl) WithConfig(userConfig *config.AgentConfig) AgentBuilder
- func (b *AgentBuilderImpl) WithLLMClient(client LLMClient) AgentBuilder
- func (b *AgentBuilderImpl) WithMaxChatCompletion(max int) AgentBuilder
- func (b *AgentBuilderImpl) WithMaxConversationHistory(max int) AgentBuilder
- func (b *AgentBuilderImpl) WithSystemPrompt(prompt string) AgentBuilder
- func (b *AgentBuilderImpl) WithToolBox(toolBox ToolBox) AgentBuilder
- type AgentTaskHandler
- type BasicTool
- type DefaultMessageHandler
- type DefaultOpenAICompatibleAgent
- func AgentWithConfig(logger *zap.Logger, config *config.AgentConfig) (*DefaultOpenAICompatibleAgent, error)
- func AgentWithLLM(logger *zap.Logger, llmClient LLMClient) (*DefaultOpenAICompatibleAgent, error)
- func FullyConfiguredAgent(logger *zap.Logger, config *config.AgentConfig, llmClient LLMClient, ...) (*DefaultOpenAICompatibleAgent, error)
- func NewDefaultOpenAICompatibleAgent(logger *zap.Logger) *DefaultOpenAICompatibleAgent
- func NewDefaultOpenAICompatibleAgentWithConfig(logger *zap.Logger, cfg *config.AgentConfig) *DefaultOpenAICompatibleAgent
- func NewOpenAICompatibleAgentWithConfig(logger *zap.Logger, config *config.AgentConfig) (*DefaultOpenAICompatibleAgent, error)
- func NewOpenAICompatibleAgentWithLLM(logger *zap.Logger, llmClient LLMClient) *DefaultOpenAICompatibleAgent
- func SimpleAgent(logger *zap.Logger) (*DefaultOpenAICompatibleAgent, error)
- func (a *DefaultOpenAICompatibleAgent) GetLLMClient() LLMClient
- func (a *DefaultOpenAICompatibleAgent) GetSystemPrompt() string
- func (a *DefaultOpenAICompatibleAgent) GetToolBox() ToolBox
- func (a *DefaultOpenAICompatibleAgent) ProcessTask(ctx context.Context, task *types.Task, message *types.Message) (*types.Task, error)
- type DefaultResponseSender
- type DefaultTaskHandler
- type DefaultTaskManager
- func (tm *DefaultTaskManager) CancelTask(taskID string) error
- func (tm *DefaultTaskManager) CleanupCompletedTasks()
- func (tm *DefaultTaskManager) CreateTask(contextID string, state types.TaskState, message *types.Message) *types.Task
- func (tm *DefaultTaskManager) DeleteTaskPushNotificationConfig(params types.DeleteTaskPushNotificationConfigParams) error
- func (tm *DefaultTaskManager) GetConversationHistory(contextID string) []types.Message
- func (tm *DefaultTaskManager) GetTask(taskID string) (*types.Task, bool)
- func (tm *DefaultTaskManager) GetTaskPushNotificationConfig(params types.GetTaskPushNotificationConfigParams) (*types.TaskPushNotificationConfig, error)
- func (tm *DefaultTaskManager) ListTaskPushNotificationConfigs(params types.ListTaskPushNotificationConfigParams) ([]types.TaskPushNotificationConfig, error)
- func (tm *DefaultTaskManager) ListTasks(params types.TaskListParams) (*types.TaskList, error)
- func (tm *DefaultTaskManager) PollTaskStatus(taskID string, interval time.Duration, timeout time.Duration) (*types.Task, error)
- func (tm *DefaultTaskManager) SetNotificationSender(sender PushNotificationSender)
- func (tm *DefaultTaskManager) SetTaskPushNotificationConfig(config types.TaskPushNotificationConfig) (*types.TaskPushNotificationConfig, error)
- func (tm *DefaultTaskManager) UpdateConversationHistory(contextID string, messages []types.Message)
- func (tm *DefaultTaskManager) UpdateTask(taskID string, state types.TaskState, message *types.Message) error
- type DefaultToolBox
- func (tb *DefaultToolBox) AddTool(tool Tool)
- func (tb *DefaultToolBox) ExecuteTool(ctx context.Context, toolName string, arguments map[string]interface{}) (string, error)
- func (tb *DefaultToolBox) GetToolNames() []string
- func (tb *DefaultToolBox) GetTools() []sdk.ChatCompletionTool
- func (tb *DefaultToolBox) HasTool(toolName string) bool
- type EmptyMessagePartsError
- type HTTPPushNotificationSender
- type JRPCErrorCode
- type LLMClient
- type MessageHandler
- type OpenAICompatibleAgent
- type OpenAICompatibleLLMClient
- func (c *OpenAICompatibleLLMClient) CreateChatCompletion(ctx context.Context, messages []sdk.Message, tools ...sdk.ChatCompletionTool) (*sdk.CreateChatCompletionResponse, error)
- func (c *OpenAICompatibleLLMClient) CreateStreamingChatCompletion(ctx context.Context, messages []sdk.Message, tools ...sdk.ChatCompletionTool) (<-chan *sdk.CreateChatCompletionStreamResponse, <-chan error)
- type PushNotificationSender
- type QueuedTask
- type ResponseSender
- type StreamingNotImplementedError
- type TaskHandler
- type TaskManager
- type TaskNotFoundError
- type TaskResultProcessor
- type TaskUpdateNotification
- type Tool
- type ToolBox
- type ToolNotFoundError
Constants ¶
This section is empty.
Variables ¶
var ( BuildAgentName = "helloworld-agent" BuildAgentDescription = "A simple greeting agent that provides personalized greetings using the A2A protocol" BuildAgentVersion = "1.0.0" )
Build-time metadata variables set via LD flags
Functions ¶
func GenerateTaskID ¶
func GenerateTaskID() string
GenerateTaskID generates a unique task ID using UUID v4
func NewEmptyMessagePartsError ¶
func NewEmptyMessagePartsError() error
NewEmptyMessagePartsError creates a new EmptyMessagePartsError
func NewStreamingNotImplementedError ¶
func NewStreamingNotImplementedError() error
NewStreamingNotImplementedError creates a new StreamingNotImplementedError
func NewTaskNotFoundError ¶
NewTaskNotFoundError creates a new TaskNotFoundError
Types ¶
type A2AServer ¶
type A2AServer interface {
// Start starts the A2A server on the configured port
Start(ctx context.Context) error
// Stop gracefully stops the A2A server
Stop(ctx context.Context) error
// GetAgentCard returns the agent's capabilities and metadata
// Returns nil if no agent card has been explicitly set
GetAgentCard() *types.AgentCard
// ProcessTask processes a task with the given message
ProcessTask(ctx context.Context, task *types.Task, message *types.Message) (*types.Task, error)
// StartTaskProcessor starts the background task processor
StartTaskProcessor(ctx context.Context)
// SetTaskHandler sets the task handler for processing tasks
SetTaskHandler(handler TaskHandler)
// GetTaskHandler returns the configured task handler
GetTaskHandler() TaskHandler
// SetAgent sets the OpenAI-compatible agent for processing tasks
SetAgent(agent OpenAICompatibleAgent)
// GetAgent returns the configured OpenAI-compatible agent
GetAgent() OpenAICompatibleAgent
// SetAgentName sets the agent's name dynamically
SetAgentName(name string)
// SetAgentDescription sets the agent's description dynamically
SetAgentDescription(description string)
// SetAgentURL sets the agent's URL dynamically
SetAgentURL(url string)
// SetAgentVersion sets the agent's version dynamically
SetAgentVersion(version string)
// SetAgentCard sets a custom agent card that overrides the default card generation
SetAgentCard(agentCard types.AgentCard)
// LoadAgentCardFromFile loads and sets an agent card from a JSON file
// The optional overrides map allows dynamic replacement of JSON attribute values
LoadAgentCardFromFile(filePath string, overrides map[string]interface{}) error
}
A2AServer defines the interface for an A2A-compatible server
func CustomA2AServer ¶
func CustomA2AServer( cfg config.Config, logger *zap.Logger, taskHandler TaskHandler, taskResultProcessor TaskResultProcessor, agentCard types.AgentCard, ) (A2AServer, error)
CustomA2AServer creates an A2A server with custom components This provides more control over the server configuration
func CustomA2AServerWithAgent ¶
func CustomA2AServerWithAgent( cfg config.Config, logger *zap.Logger, agent OpenAICompatibleAgent, toolBox ToolBox, taskResultProcessor TaskResultProcessor, agentCard types.AgentCard, ) (A2AServer, error)
CustomA2AServerWithAgent creates an A2A server with custom components and an agent This provides maximum control over the server configuration
func SimpleA2AServerWithAgent ¶
func SimpleA2AServerWithAgent(cfg config.Config, logger *zap.Logger, agent OpenAICompatibleAgent, agentCard types.AgentCard) (A2AServer, error)
SimpleA2AServerWithAgent creates a basic A2A server with an OpenAI-compatible agent This is a convenience function for agent-based use cases
type A2AServerBuilder ¶
type A2AServerBuilder interface {
// WithTaskHandler sets a custom task handler for processing A2A tasks.
// If not set, a default task handler will be used.
WithTaskHandler(handler TaskHandler) A2AServerBuilder
// WithTaskResultProcessor sets a custom task result processor for handling tool call results.
// This allows custom business logic for determining when tasks should be completed.
WithTaskResultProcessor(processor TaskResultProcessor) A2AServerBuilder
// WithAgent sets a pre-configured OpenAI-compatible agent for processing tasks.
// This is useful when you have already configured an agent with specific settings.
WithAgent(agent OpenAICompatibleAgent) A2AServerBuilder
// WithAgentCard sets a custom agent card that overrides the default card generation.
// This gives full control over the agent's advertised capabilities and metadata.
WithAgentCard(agentCard types.AgentCard) A2AServerBuilder
// WithAgentCardFromFile loads and sets an agent card from a JSON file.
// This provides a convenient way to load agent configuration from a static file.
// The optional overrides map allows dynamic replacement of JSON attribute values.
WithAgentCardFromFile(filePath string, overrides map[string]interface{}) A2AServerBuilder
// WithLogger sets a custom logger for the builder and resulting server.
// This allows using a logger configured with appropriate level based on the Debug config.
WithLogger(logger *zap.Logger) A2AServerBuilder
// Build creates and returns the configured A2A server.
// This method applies configuration defaults and initializes all components.
Build() (A2AServer, error)
}
A2AServerBuilder provides a fluent interface for building A2A servers with custom configurations. This interface allows for flexible server construction with optional components and settings. Use NewA2AServerBuilder to create an instance, then chain method calls to configure the server.
Example:
server := NewA2AServerBuilder(config, logger). WithAgent(agent). Build()
func NewA2AServerBuilder ¶
func NewA2AServerBuilder(cfg config.Config, logger *zap.Logger) A2AServerBuilder
NewA2AServerBuilder creates a new server builder with required dependencies. The configuration passed here will be used to configure the server. Any nil nested configuration objects will be populated with sensible defaults when Build() is called.
Parameters:
- cfg: The base configuration for the server (agent name, port, etc.)
- logger: Logger instance to use for the server (should match cfg.Debug level)
Returns:
A2AServerBuilder interface that can be used to further configure the server before building.
Example:
cfg := config.Config{
AgentName: "my-agent",
Port: "8080",
Debug: true,
}
logger, _ := zap.NewDevelopment() // Use development logger for debug
server := NewA2AServerBuilder(cfg, logger).
WithAgent(myAgent).
Build()
type A2AServerBuilderImpl ¶
type A2AServerBuilderImpl struct {
// contains filtered or unexported fields
}
A2AServerBuilderImpl is the concrete implementation of the A2AServerBuilder interface. It provides a fluent interface for building A2A servers with custom configurations. This struct holds the configuration and optional components that will be used to create the server.
func (*A2AServerBuilderImpl) Build ¶
func (b *A2AServerBuilderImpl) Build() (A2AServer, error)
Build creates and returns the configured A2A server.
func (*A2AServerBuilderImpl) WithAgent ¶
func (b *A2AServerBuilderImpl) WithAgent(agent OpenAICompatibleAgent) A2AServerBuilder
WithAgent sets a custom OpenAI-compatible agent
func (*A2AServerBuilderImpl) WithAgentCard ¶
func (b *A2AServerBuilderImpl) WithAgentCard(agentCard types.AgentCard) A2AServerBuilder
WithAgentCard sets a custom agent card that overrides the default card generation
func (*A2AServerBuilderImpl) WithAgentCardFromFile ¶
func (b *A2AServerBuilderImpl) WithAgentCardFromFile(filePath string, overrides map[string]interface{}) A2AServerBuilder
WithAgentCardFromFile loads and sets an agent card from a JSON file The optional overrides map allows dynamic replacement of JSON attribute values
func (*A2AServerBuilderImpl) WithLogger ¶
func (b *A2AServerBuilderImpl) WithLogger(logger *zap.Logger) A2AServerBuilder
WithLogger sets a custom logger for the builder
func (*A2AServerBuilderImpl) WithTaskHandler ¶
func (b *A2AServerBuilderImpl) WithTaskHandler(handler TaskHandler) A2AServerBuilder
WithTaskHandler sets a custom task handler
func (*A2AServerBuilderImpl) WithTaskResultProcessor ¶
func (b *A2AServerBuilderImpl) WithTaskResultProcessor(processor TaskResultProcessor) A2AServerBuilder
WithTaskResultProcessor sets a custom task result processor
type A2AServerImpl ¶
type A2AServerImpl struct {
// contains filtered or unexported fields
}
func NewA2AServer ¶
func NewA2AServer(cfg *config.Config, logger *zap.Logger, otel otel.OpenTelemetry) *A2AServerImpl
NewA2AServer creates a new A2A server with the provided configuration and logger
func NewA2AServerEnvironmentAware ¶
func NewA2AServerEnvironmentAware(cfg *config.Config, logger *zap.Logger, otel otel.OpenTelemetry) *A2AServerImpl
NewA2AServerEnvironmentAware creates a new A2A server with environment-aware configuration.
func NewA2AServerWithAgent ¶
func NewA2AServerWithAgent(cfg *config.Config, logger *zap.Logger, otel otel.OpenTelemetry, agent OpenAICompatibleAgent) *A2AServerImpl
NewA2AServerWithAgent creates a new A2A server with an optional OpenAI-compatible agent
func NewDefaultA2AServer ¶
func NewDefaultA2AServer(cfg *config.Config) *A2AServerImpl
NewDefaultA2AServer creates a new default A2A server implementation
func (*A2AServerImpl) GetAgent ¶
func (s *A2AServerImpl) GetAgent() OpenAICompatibleAgent
GetAgent returns the configured OpenAI-compatible agent
func (*A2AServerImpl) GetAgentCard ¶
func (s *A2AServerImpl) GetAgentCard() *types.AgentCard
GetAgentCard returns the agent's capabilities and metadata Returns nil if no agent card has been explicitly set
func (*A2AServerImpl) GetTaskHandler ¶
func (s *A2AServerImpl) GetTaskHandler() TaskHandler
GetTaskHandler returns the configured task handler
func (*A2AServerImpl) LoadAgentCardFromFile ¶
func (s *A2AServerImpl) LoadAgentCardFromFile(filePath string, overrides map[string]interface{}) error
LoadAgentCardFromFile loads and sets an agent card from a JSON file The optional overrides map allows dynamic replacement of JSON attribute values
func (*A2AServerImpl) ProcessTask ¶
func (s *A2AServerImpl) ProcessTask(ctx context.Context, task *types.Task, message *types.Message) (*types.Task, error)
ProcessTask processes a task with the given message
func (*A2AServerImpl) SetAgent ¶
func (s *A2AServerImpl) SetAgent(agent OpenAICompatibleAgent)
SetAgent sets the OpenAI-compatible agent for processing tasks
func (*A2AServerImpl) SetAgentCard ¶
func (s *A2AServerImpl) SetAgentCard(agentCard types.AgentCard)
SetAgentCard sets a custom agent card that overrides the default card generation
func (*A2AServerImpl) SetAgentDescription ¶
func (s *A2AServerImpl) SetAgentDescription(description string)
SetAgentDescription sets the agent's description dynamically
func (*A2AServerImpl) SetAgentName ¶
func (s *A2AServerImpl) SetAgentName(name string)
SetAgentName sets the agent's name dynamically
func (*A2AServerImpl) SetAgentURL ¶
func (s *A2AServerImpl) SetAgentURL(url string)
SetAgentURL sets the agent's URL dynamically
func (*A2AServerImpl) SetAgentVersion ¶
func (s *A2AServerImpl) SetAgentVersion(version string)
SetAgentVersion sets the agent's version dynamically
func (*A2AServerImpl) SetTaskHandler ¶
func (s *A2AServerImpl) SetTaskHandler(handler TaskHandler)
SetTaskHandler allows injecting a custom task handler
func (*A2AServerImpl) SetTaskResultProcessor ¶
func (s *A2AServerImpl) SetTaskResultProcessor(processor TaskResultProcessor)
SetTaskResultProcessor sets the task result processor for custom business logic
func (*A2AServerImpl) Start ¶
func (s *A2AServerImpl) Start(ctx context.Context) error
Start starts the A2A server
func (*A2AServerImpl) StartTaskProcessor ¶
func (s *A2AServerImpl) StartTaskProcessor(ctx context.Context)
StartTaskProcessor starts the background task processing goroutine
type AgentBuilder ¶
type AgentBuilder interface {
// WithConfig sets the agent configuration
WithConfig(config *config.AgentConfig) AgentBuilder
// WithLLMClient sets a pre-configured LLM client
WithLLMClient(client LLMClient) AgentBuilder
// WithToolBox sets a custom toolbox
WithToolBox(toolBox ToolBox) AgentBuilder
// WithSystemPrompt sets the system prompt (overrides config)
WithSystemPrompt(prompt string) AgentBuilder
// WithMaxChatCompletion sets the maximum chat completion iterations for the agent
WithMaxChatCompletion(max int) AgentBuilder
// WithMaxConversationHistory sets the maximum conversation history for the agent
WithMaxConversationHistory(max int) AgentBuilder
// GetConfig returns the current agent configuration (for testing purposes)
GetConfig() *config.AgentConfig
// Build creates and returns the configured agent
Build() (*DefaultOpenAICompatibleAgent, error)
}
AgentBuilder provides a fluent interface for building OpenAI-compatible agents with custom configurations. This interface allows for flexible agent construction with optional components and settings. Use NewAgentBuilder to create an instance, then chain method calls to configure the agent.
Example:
agent := NewAgentBuilder(logger). WithConfig(agentConfig). WithLLMClient(client). Build()
func NewAgentBuilder ¶
func NewAgentBuilder(logger *zap.Logger) AgentBuilder
NewAgentBuilder creates a new agent builder with required dependencies.
Parameters:
- logger: Logger instance to use for the agent
Returns:
AgentBuilder interface that can be used to configure the agent before building.
Example:
logger, _ := zap.NewDevelopment() agent, err := NewAgentBuilder(logger). WithConfig(agentConfig). Build()
type AgentBuilderImpl ¶
type AgentBuilderImpl struct {
// contains filtered or unexported fields
}
AgentBuilderImpl is the concrete implementation of the AgentBuilder interface. It provides a fluent interface for building OpenAI-compatible agents with custom configurations.
func (*AgentBuilderImpl) Build ¶
func (b *AgentBuilderImpl) Build() (*DefaultOpenAICompatibleAgent, error)
Build creates and returns the configured agent
func (*AgentBuilderImpl) GetConfig ¶
func (b *AgentBuilderImpl) GetConfig() *config.AgentConfig
GetConfig returns the current agent configuration (for testing purposes)
func (*AgentBuilderImpl) WithConfig ¶
func (b *AgentBuilderImpl) WithConfig(userConfig *config.AgentConfig) AgentBuilder
WithConfig sets the agent configuration
func (*AgentBuilderImpl) WithLLMClient ¶
func (b *AgentBuilderImpl) WithLLMClient(client LLMClient) AgentBuilder
WithLLMClient sets a pre-configured LLM client
func (*AgentBuilderImpl) WithMaxChatCompletion ¶
func (b *AgentBuilderImpl) WithMaxChatCompletion(max int) AgentBuilder
WithMaxChatCompletion sets the maximum chat completion iterations for the agent
func (*AgentBuilderImpl) WithMaxConversationHistory ¶
func (b *AgentBuilderImpl) WithMaxConversationHistory(max int) AgentBuilder
WithMaxConversationHistory sets the maximum conversation history for the agent
func (*AgentBuilderImpl) WithSystemPrompt ¶
func (b *AgentBuilderImpl) WithSystemPrompt(prompt string) AgentBuilder
WithSystemPrompt sets the system prompt (overrides config)
func (*AgentBuilderImpl) WithToolBox ¶
func (b *AgentBuilderImpl) WithToolBox(toolBox ToolBox) AgentBuilder
WithToolBox sets a custom toolbox
type AgentTaskHandler ¶
type AgentTaskHandler struct {
// contains filtered or unexported fields
}
AgentTaskHandler is a TaskHandler that delegates to an OpenAICompatibleAgent
func NewAgentTaskHandler ¶
func NewAgentTaskHandler(logger *zap.Logger, agent OpenAICompatibleAgent) *AgentTaskHandler
NewAgentTaskHandler creates a new task handler that uses an OpenAI-compatible agent
type BasicTool ¶
type BasicTool struct {
// contains filtered or unexported fields
}
BasicTool is a simple implementation of the Tool interface using function callbacks
func NewBasicTool ¶
func NewBasicTool( name string, description string, parameters map[string]interface{}, executor func(ctx context.Context, arguments map[string]interface{}) (string, error), ) *BasicTool
NewBasicTool creates a new BasicTool
func (*BasicTool) GetDescription ¶
func (*BasicTool) GetParameters ¶
type DefaultMessageHandler ¶
type DefaultMessageHandler struct {
// contains filtered or unexported fields
}
DefaultMessageHandler implements the MessageHandler interface
func NewDefaultMessageHandler ¶
func NewDefaultMessageHandler(logger *zap.Logger, taskManager TaskManager, cfg *config.Config) *DefaultMessageHandler
NewDefaultMessageHandler creates a new default message handler
func NewDefaultMessageHandlerWithAgent ¶
func NewDefaultMessageHandlerWithAgent(logger *zap.Logger, taskManager TaskManager, agent OpenAICompatibleAgent, cfg *config.Config) *DefaultMessageHandler
NewDefaultMessageHandlerWithAgent creates a new default message handler with an agent for streaming
func (*DefaultMessageHandler) HandleMessageSend ¶
func (mh *DefaultMessageHandler) HandleMessageSend(ctx context.Context, params types.MessageSendParams) (*types.Task, error)
HandleMessageSend processes message/send requests
func (*DefaultMessageHandler) HandleMessageStream ¶
func (mh *DefaultMessageHandler) HandleMessageStream(ctx context.Context, params types.MessageSendParams, responseChan chan<- types.SendStreamingMessageResponse) error
HandleMessageStream processes message/stream requests (for streaming responses)
type DefaultOpenAICompatibleAgent ¶
type DefaultOpenAICompatibleAgent struct {
// contains filtered or unexported fields
}
DefaultOpenAICompatibleAgent is the default implementation of OpenAICompatibleAgent
func AgentWithConfig ¶
func AgentWithConfig(logger *zap.Logger, config *config.AgentConfig) (*DefaultOpenAICompatibleAgent, error)
AgentWithConfig creates an agent with the provided configuration
func AgentWithLLM ¶
func AgentWithLLM(logger *zap.Logger, llmClient LLMClient) (*DefaultOpenAICompatibleAgent, error)
AgentWithLLM creates an agent with a pre-configured LLM client
func FullyConfiguredAgent ¶
func FullyConfiguredAgent(logger *zap.Logger, config *config.AgentConfig, llmClient LLMClient, toolBox ToolBox) (*DefaultOpenAICompatibleAgent, error)
FullyConfiguredAgent creates an agent with all components configured
func NewDefaultOpenAICompatibleAgent ¶
func NewDefaultOpenAICompatibleAgent(logger *zap.Logger) *DefaultOpenAICompatibleAgent
NewDefaultOpenAICompatibleAgent creates a new DefaultOpenAICompatibleAgent
func NewDefaultOpenAICompatibleAgentWithConfig ¶
func NewDefaultOpenAICompatibleAgentWithConfig(logger *zap.Logger, cfg *config.AgentConfig) *DefaultOpenAICompatibleAgent
NewDefaultOpenAICompatibleAgentWithConfig creates a new DefaultOpenAICompatibleAgent with configuration
func NewOpenAICompatibleAgentWithConfig ¶
func NewOpenAICompatibleAgentWithConfig(logger *zap.Logger, config *config.AgentConfig) (*DefaultOpenAICompatibleAgent, error)
NewOpenAICompatibleAgentWithConfig creates a new agent with LLM configuration
func NewOpenAICompatibleAgentWithLLM ¶
func NewOpenAICompatibleAgentWithLLM(logger *zap.Logger, llmClient LLMClient) *DefaultOpenAICompatibleAgent
NewOpenAICompatibleAgentWithLLM creates a new agent with an LLM client
func SimpleAgent ¶
func SimpleAgent(logger *zap.Logger) (*DefaultOpenAICompatibleAgent, error)
SimpleAgent creates a basic agent with default configuration
func (*DefaultOpenAICompatibleAgent) GetLLMClient ¶
func (a *DefaultOpenAICompatibleAgent) GetLLMClient() LLMClient
GetLLMClient returns the LLM client for external use (e.g., streaming)
func (*DefaultOpenAICompatibleAgent) GetSystemPrompt ¶
func (a *DefaultOpenAICompatibleAgent) GetSystemPrompt() string
GetSystemPrompt returns the system prompt configured for the agent
func (*DefaultOpenAICompatibleAgent) GetToolBox ¶
func (a *DefaultOpenAICompatibleAgent) GetToolBox() ToolBox
GetToolBox returns the tool box for external use (e.g., streaming)
type DefaultResponseSender ¶
type DefaultResponseSender struct {
// contains filtered or unexported fields
}
DefaultResponseSender implements the ResponseSender interface
func NewDefaultResponseSender ¶
func NewDefaultResponseSender(logger *zap.Logger) *DefaultResponseSender
NewDefaultResponseSender creates a new default response sender
func (*DefaultResponseSender) SendError ¶
func (rs *DefaultResponseSender) SendError(c *gin.Context, id interface{}, code int, message string)
SendError sends a JSON-RPC error response
func (*DefaultResponseSender) SendSuccess ¶
func (rs *DefaultResponseSender) SendSuccess(c *gin.Context, id interface{}, result interface{})
SendSuccess sends a JSON-RPC success response
type DefaultTaskHandler ¶
type DefaultTaskHandler struct {
// contains filtered or unexported fields
}
DefaultTaskHandler implements the TaskHandler interface This handler throws an error to enforce using proper handlers like AgentTaskHandler
func NewDefaultTaskHandler ¶
func NewDefaultTaskHandler(logger *zap.Logger) *DefaultTaskHandler
NewDefaultTaskHandler creates a new default task handler
type DefaultTaskManager ¶
type DefaultTaskManager struct {
// contains filtered or unexported fields
}
DefaultTaskManager implements the TaskManager interface
func NewDefaultTaskManager ¶
func NewDefaultTaskManager(logger *zap.Logger, maxConversationHistory int) *DefaultTaskManager
NewDefaultTaskManager creates a new default task manager
func NewDefaultTaskManagerWithNotifications ¶
func NewDefaultTaskManagerWithNotifications(logger *zap.Logger, maxConversationHistory int, notificationSender PushNotificationSender) *DefaultTaskManager
NewDefaultTaskManagerWithNotifications creates a new default task manager with push notification support
func (*DefaultTaskManager) CancelTask ¶
func (tm *DefaultTaskManager) CancelTask(taskID string) error
CancelTask cancels a task
func (*DefaultTaskManager) CleanupCompletedTasks ¶
func (tm *DefaultTaskManager) CleanupCompletedTasks()
CleanupCompletedTasks removes old completed tasks from memory
func (*DefaultTaskManager) CreateTask ¶
func (tm *DefaultTaskManager) CreateTask(contextID string, state types.TaskState, message *types.Message) *types.Task
CreateTask creates a new task and stores it
func (*DefaultTaskManager) DeleteTaskPushNotificationConfig ¶
func (tm *DefaultTaskManager) DeleteTaskPushNotificationConfig(params types.DeleteTaskPushNotificationConfigParams) error
DeleteTaskPushNotificationConfig deletes a push notification configuration
func (*DefaultTaskManager) GetConversationHistory ¶
func (tm *DefaultTaskManager) GetConversationHistory(contextID string) []types.Message
GetConversationHistory retrieves conversation history for a context ID
func (*DefaultTaskManager) GetTask ¶
func (tm *DefaultTaskManager) GetTask(taskID string) (*types.Task, bool)
GetTask retrieves a task by ID
func (*DefaultTaskManager) GetTaskPushNotificationConfig ¶
func (tm *DefaultTaskManager) GetTaskPushNotificationConfig(params types.GetTaskPushNotificationConfigParams) (*types.TaskPushNotificationConfig, error)
GetTaskPushNotificationConfig gets push notification configuration for a task
func (*DefaultTaskManager) ListTaskPushNotificationConfigs ¶
func (tm *DefaultTaskManager) ListTaskPushNotificationConfigs(params types.ListTaskPushNotificationConfigParams) ([]types.TaskPushNotificationConfig, error)
ListTaskPushNotificationConfigs lists all push notification configurations for a task
func (*DefaultTaskManager) ListTasks ¶
func (tm *DefaultTaskManager) ListTasks(params types.TaskListParams) (*types.TaskList, error)
ListTasks retrieves a list of tasks based on the provided parameters
func (*DefaultTaskManager) PollTaskStatus ¶
func (tm *DefaultTaskManager) PollTaskStatus(taskID string, interval time.Duration, timeout time.Duration) (*types.Task, error)
PollTaskStatus periodically checks the status of a task until it is completed or failed
func (*DefaultTaskManager) SetNotificationSender ¶
func (tm *DefaultTaskManager) SetNotificationSender(sender PushNotificationSender)
SetNotificationSender sets the push notification sender
func (*DefaultTaskManager) SetTaskPushNotificationConfig ¶
func (tm *DefaultTaskManager) SetTaskPushNotificationConfig(config types.TaskPushNotificationConfig) (*types.TaskPushNotificationConfig, error)
SetTaskPushNotificationConfig sets push notification configuration for a task
func (*DefaultTaskManager) UpdateConversationHistory ¶
func (tm *DefaultTaskManager) UpdateConversationHistory(contextID string, messages []types.Message)
UpdateConversationHistory updates conversation history for a context ID
func (*DefaultTaskManager) UpdateTask ¶
func (tm *DefaultTaskManager) UpdateTask(taskID string, state types.TaskState, message *types.Message) error
UpdateTask updates an existing task
type DefaultToolBox ¶
type DefaultToolBox struct {
// contains filtered or unexported fields
}
DefaultToolBox is a default implementation of ToolBox
func NewDefaultToolBox ¶
func NewDefaultToolBox() *DefaultToolBox
NewDefaultToolBox creates a new DefaultToolBox
func (*DefaultToolBox) AddTool ¶
func (tb *DefaultToolBox) AddTool(tool Tool)
AddTool adds a tool to the toolbox
func (*DefaultToolBox) ExecuteTool ¶
func (tb *DefaultToolBox) ExecuteTool(ctx context.Context, toolName string, arguments map[string]interface{}) (string, error)
ExecuteTool executes a tool by name with the provided arguments
func (*DefaultToolBox) GetToolNames ¶
func (tb *DefaultToolBox) GetToolNames() []string
GetToolNames returns a list of all available tool names
func (*DefaultToolBox) GetTools ¶
func (tb *DefaultToolBox) GetTools() []sdk.ChatCompletionTool
GetTools returns all available tools in OpenAI function call format
func (*DefaultToolBox) HasTool ¶
func (tb *DefaultToolBox) HasTool(toolName string) bool
HasTool checks if a tool with the given name exists
type EmptyMessagePartsError ¶
type EmptyMessagePartsError struct{}
EmptyMessagePartsError represents an error for empty message parts
func (*EmptyMessagePartsError) Error ¶
func (e *EmptyMessagePartsError) Error() string
type HTTPPushNotificationSender ¶
type HTTPPushNotificationSender struct {
// contains filtered or unexported fields
}
HTTPPushNotificationSender implements push notifications via HTTP webhooks
func NewHTTPPushNotificationSender ¶
func NewHTTPPushNotificationSender(logger *zap.Logger) *HTTPPushNotificationSender
NewHTTPPushNotificationSender creates a new HTTP-based push notification sender
func (*HTTPPushNotificationSender) SendTaskUpdate ¶
func (s *HTTPPushNotificationSender) SendTaskUpdate(ctx context.Context, config types.PushNotificationConfig, task *types.Task) error
SendTaskUpdate sends a push notification about a task update
type JRPCErrorCode ¶
type JRPCErrorCode int
JRPCErrorCode represents JSON-RPC error codes
const ( ErrParseError JRPCErrorCode = -32700 ErrInvalidRequest JRPCErrorCode = -32600 ErrMethodNotFound JRPCErrorCode = -32601 ErrInvalidParams JRPCErrorCode = -32602 ErrInternalError JRPCErrorCode = -32603 ErrServerError JRPCErrorCode = -32000 )
type LLMClient ¶
type LLMClient interface {
// CreateChatCompletion sends a chat completion request using SDK messages
CreateChatCompletion(ctx context.Context, messages []sdk.Message, tools ...sdk.ChatCompletionTool) (*sdk.CreateChatCompletionResponse, error)
// CreateStreamingChatCompletion sends a streaming chat completion request using SDK messages
CreateStreamingChatCompletion(ctx context.Context, messages []sdk.Message, tools ...sdk.ChatCompletionTool) (<-chan *sdk.CreateChatCompletionStreamResponse, <-chan error)
}
LLMClient defines the interface for Language Model clients
type MessageHandler ¶
type MessageHandler interface {
// HandleMessageSend processes message/send requests
HandleMessageSend(ctx context.Context, params types.MessageSendParams) (*types.Task, error)
// HandleMessageStream processes message/stream requests (for streaming responses)
HandleMessageStream(ctx context.Context, params types.MessageSendParams, responseChan chan<- types.SendStreamingMessageResponse) error
}
MessageHandler defines how to handle different types of A2A messages
type OpenAICompatibleAgent ¶
type OpenAICompatibleAgent interface {
// ProcessTask processes a task with optional tool calling capabilities
ProcessTask(ctx context.Context, task *types.Task, message *types.Message) (*types.Task, error)
// GetLLMClient returns the LLM client for external use (e.g., streaming)
GetLLMClient() LLMClient
// GetToolBox returns the tool box for external use (e.g., streaming)
GetToolBox() ToolBox
// GetSystemPrompt returns the system prompt configured for the agent
GetSystemPrompt() string
}
OpenAICompatibleAgent represents an agent that can interact with OpenAI-compatible LLM APIs and execute tools
type OpenAICompatibleLLMClient ¶
type OpenAICompatibleLLMClient struct {
// contains filtered or unexported fields
}
OpenAICompatibleLLMClient implements LLMClient using an OpenAI-compatible API via the Inference Gateway SDK
func NewOpenAICompatibleLLMClient ¶
func NewOpenAICompatibleLLMClient(cfg *config.AgentConfig, logger *zap.Logger) (*OpenAICompatibleLLMClient, error)
NewOpenAICompatibleLLMClient creates a new OpenAI-compatible LLM client
func (*OpenAICompatibleLLMClient) CreateChatCompletion ¶
func (c *OpenAICompatibleLLMClient) CreateChatCompletion(ctx context.Context, messages []sdk.Message, tools ...sdk.ChatCompletionTool) (*sdk.CreateChatCompletionResponse, error)
CreateChatCompletion implements LLMClient.CreateChatCompletion using SDK messages
func (*OpenAICompatibleLLMClient) CreateStreamingChatCompletion ¶
func (c *OpenAICompatibleLLMClient) CreateStreamingChatCompletion(ctx context.Context, messages []sdk.Message, tools ...sdk.ChatCompletionTool) (<-chan *sdk.CreateChatCompletionStreamResponse, <-chan error)
CreateStreamingChatCompletion implements LLMClient.CreateStreamingChatCompletion using SDK messages
type PushNotificationSender ¶
type PushNotificationSender interface {
SendTaskUpdate(ctx context.Context, config types.PushNotificationConfig, task *types.Task) error
}
PushNotificationSender handles sending push notifications
type QueuedTask ¶
QueuedTask represents a task in the processing queue
type ResponseSender ¶
type ResponseSender interface {
// SendSuccess sends a JSON-RPC success response
SendSuccess(c *gin.Context, id interface{}, result interface{})
// SendError sends a JSON-RPC error response
SendError(c *gin.Context, id interface{}, code int, message string)
}
ResponseSender defines how to send JSON-RPC responses
type StreamingNotImplementedError ¶
type StreamingNotImplementedError struct{}
StreamingNotImplementedError represents an error for unimplemented streaming
func (*StreamingNotImplementedError) Error ¶
func (e *StreamingNotImplementedError) Error() string
type TaskHandler ¶
type TaskHandler interface {
// HandleTask processes a task and returns the updated task
// This is where the main business logic should be implemented
HandleTask(ctx context.Context, task *types.Task, message *types.Message) (*types.Task, error)
}
TaskHandler defines how to handle task processing This interface should be implemented by domain-specific task handlers
type TaskManager ¶
type TaskManager interface {
// CreateTask creates a new task and stores it
CreateTask(contextID string, state types.TaskState, message *types.Message) *types.Task
// UpdateTask updates an existing task
UpdateTask(taskID string, state types.TaskState, message *types.Message) error
// GetTask retrieves a task by ID
GetTask(taskID string) (*types.Task, bool)
// ListTasks retrieves a list of tasks based on the provided parameters
ListTasks(params types.TaskListParams) (*types.TaskList, error)
// CancelTask cancels a task
CancelTask(taskID string) error
// CleanupCompletedTasks removes old completed tasks from memory
CleanupCompletedTasks()
// PollTaskStatus periodically checks the status of a task until it is completed or failed
PollTaskStatus(taskID string, interval time.Duration, timeout time.Duration) (*types.Task, error)
// GetConversationHistory retrieves conversation history for a context ID
GetConversationHistory(contextID string) []types.Message
// UpdateConversationHistory updates conversation history for a context ID
UpdateConversationHistory(contextID string, messages []types.Message)
// SetTaskPushNotificationConfig sets push notification configuration for a task
SetTaskPushNotificationConfig(config types.TaskPushNotificationConfig) (*types.TaskPushNotificationConfig, error)
// GetTaskPushNotificationConfig gets push notification configuration for a task
GetTaskPushNotificationConfig(params types.GetTaskPushNotificationConfigParams) (*types.TaskPushNotificationConfig, error)
// ListTaskPushNotificationConfigs lists all push notification configurations for a task
ListTaskPushNotificationConfigs(params types.ListTaskPushNotificationConfigParams) ([]types.TaskPushNotificationConfig, error)
// DeleteTaskPushNotificationConfig deletes a push notification configuration
DeleteTaskPushNotificationConfig(params types.DeleteTaskPushNotificationConfigParams) error
}
TaskManager defines task lifecycle management
type TaskNotFoundError ¶
type TaskNotFoundError struct {
TaskID string
}
TaskNotFoundError represents an error when a task is not found
func (*TaskNotFoundError) Error ¶
func (e *TaskNotFoundError) Error() string
type TaskResultProcessor ¶
type TaskResultProcessor interface {
// ProcessToolResult processes a tool call result and returns a completion message if the task should be completed
// Returns nil if the task should continue processing
ProcessToolResult(toolCallResult string) *types.Message
}
TaskResultProcessor defines how to process tool call results for task completion
type TaskUpdateNotification ¶
type TaskUpdateNotification struct {
Type string `json:"type"`
TaskID string `json:"taskId"`
State string `json:"state"`
Timestamp string `json:"timestamp"`
Task *types.Task `json:"task,omitempty"`
}
TaskUpdateNotification represents the payload sent to webhook URLs
type Tool ¶
type Tool interface {
// GetName returns the name of the tool
GetName() string
// GetDescription returns a description of what the tool does
GetDescription() string
// GetParameters returns the JSON schema for the tool parameters
GetParameters() map[string]interface{}
// Execute runs the tool with the provided arguments
Execute(ctx context.Context, arguments map[string]interface{}) (string, error)
}
Tool represents a single tool that can be executed
type ToolBox ¶
type ToolBox interface {
// GetTools returns all available tools in OpenAI function call format
GetTools() []sdk.ChatCompletionTool
// ExecuteTool executes a tool by name with the provided arguments
// Returns the tool result as a string and any error that occurred
ExecuteTool(ctx context.Context, toolName string, arguments map[string]interface{}) (string, error)
// GetToolNames returns a list of all available tool names
GetToolNames() []string
// HasTool checks if a tool with the given name exists
HasTool(toolName string) bool
}
ToolBox defines the interface for a collection of tools that can be used by OpenAI-compatible agents
type ToolNotFoundError ¶
type ToolNotFoundError struct {
ToolName string
}
ToolNotFoundError represents an error when a requested tool is not found
func (*ToolNotFoundError) Error ¶
func (e *ToolNotFoundError) Error() string