client

package
v0.9.4-rc.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type A2AClient

type A2AClient interface {
	// Agent discovery
	GetAgentCard(ctx context.Context) (*types.AgentCard, error)
	GetHealth(ctx context.Context) (*HealthResponse, error)

	// Task operations
	SendTask(ctx context.Context, params types.MessageSendParams) (*types.JSONRPCSuccessResponse, error)
	SendTaskStreaming(ctx context.Context, params types.MessageSendParams, eventChan chan<- any) error
	GetTask(ctx context.Context, params types.TaskQueryParams) (*types.JSONRPCSuccessResponse, error)
	ListTasks(ctx context.Context, params types.TaskListParams) (*types.JSONRPCSuccessResponse, error)
	CancelTask(ctx context.Context, params types.TaskIdParams) (*types.JSONRPCSuccessResponse, error)

	// Configuration
	SetTimeout(timeout time.Duration)
	SetHTTPClient(client *http.Client)
	GetBaseURL() string

	// Logger configuration
	SetLogger(logger *zap.Logger)
	GetLogger() *zap.Logger
}

A2AClient defines the interface for an A2A protocol client

func NewClient

func NewClient(baseURL string) A2AClient

NewClient creates a new A2A client with default configuration

func NewClientWithConfig

func NewClientWithConfig(config *Config) A2AClient

NewClientWithConfig creates a new A2A client with custom configuration

func NewClientWithLogger

func NewClientWithLogger(baseURL string, logger *zap.Logger) A2AClient

NewClientWithLogger creates a new A2A client with a custom logger

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents an A2A protocol client

func (*Client) CancelTask

func (c *Client) CancelTask(ctx context.Context, params types.TaskIdParams) (*types.JSONRPCSuccessResponse, error)

CancelTaskWithContext cancels a task with context support

func (*Client) GetAgentCard

func (c *Client) GetAgentCard(ctx context.Context) (*types.AgentCard, error)

GetAgentCard retrieves the agent card information via HTTP GET to .well-known/agent.json

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() string

GetBaseURL returns the base URL of the client

func (*Client) GetConfig

func (c *Client) GetConfig() Config

GetConfig returns a copy of the client configuration

func (*Client) GetHealth

func (c *Client) GetHealth(ctx context.Context) (*HealthResponse, error)

GetHealth retrieves the health status of the agent via HTTP GET to /health

func (*Client) GetLogger

func (c *Client) GetLogger() *zap.Logger

GetLogger returns the current logger

func (*Client) GetTask

GetTaskWithContext retrieves the status of a task with context support

func (*Client) ListTasks

ListTasks retrieves a list of tasks from the agent

func (*Client) RemoveHeader

func (c *Client) RemoveHeader(key string)

RemoveHeader removes a custom header

func (*Client) SendTask

SendTask sends a task to the agent (primary interface following official A2A pattern)

func (*Client) SendTaskStreaming

func (c *Client) SendTaskStreaming(ctx context.Context, params types.MessageSendParams, eventChan chan<- any) error

SendTaskStreaming sends a task and streams the response (primary interface following official A2A pattern)

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(client *http.Client)

SetHTTPClient allows customizing the HTTP client

func (*Client) SetHeader

func (c *Client) SetHeader(key, value string)

SetHeader sets a custom header for all requests

func (*Client) SetLogger

func (c *Client) SetLogger(logger *zap.Logger)

SetLogger sets the logger for the client

func (*Client) SetMaxRetries

func (c *Client) SetMaxRetries(maxRetries int)

SetMaxRetries sets the maximum number of retry attempts

func (*Client) SetRetryDelay

func (c *Client) SetRetryDelay(delay time.Duration)

SetRetryDelay sets the delay between retry attempts

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for HTTP requests

type Config

type Config struct {
	BaseURL    string
	Timeout    time.Duration
	HTTPClient *http.Client
	UserAgent  string
	Headers    map[string]string
	MaxRetries int
	RetryDelay time.Duration
	Logger     *zap.Logger
}

Config holds configuration options for the A2A client

func DefaultConfig

func DefaultConfig(baseURL string) *Config

DefaultConfig returns a default configuration

type HealthResponse

type HealthResponse struct {
	Status string `json:"status"`
}

HealthResponse represents the response from the health endpoint

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL