Documentation
¶
Index ¶
- type A2AClient
- type ArtifactHelper
- func (ah *ArtifactHelper) DownloadAllArtifacts(ctx context.Context, task *types.Task, config *DownloadConfig) ([]*DownloadResult, error)
- func (ah *ArtifactHelper) DownloadArtifact(ctx context.Context, artifact *types.Artifact, config *DownloadConfig) ([]*DownloadResult, error)
- func (ah *ArtifactHelper) DownloadFileData(ctx context.Context, fileData FileData, config *DownloadConfig) (*DownloadResult, error)
- func (ah *ArtifactHelper) ExtractArtifactUpdateFromStreamEvent(eventData any) (*types.TaskArtifactUpdateEvent, bool)
- func (ah *ArtifactHelper) ExtractArtifactsFromTask(task *types.Task) []types.Artifact
- func (ah *ArtifactHelper) ExtractDataFromArtifact(artifact *types.Artifact) []map[string]any
- func (ah *ArtifactHelper) ExtractFileDataFromArtifact(artifact *types.Artifact) ([]FileData, error)
- func (ah *ArtifactHelper) ExtractTaskFromResponse(response *types.JSONRPCSuccessResponse) (*types.Task, error)
- func (ah *ArtifactHelper) ExtractTextFromArtifact(artifact *types.Artifact) []string
- func (ah *ArtifactHelper) FilterArtifactsByName(task *types.Task, namePattern string) []types.Artifact
- func (ah *ArtifactHelper) GetArtifactByID(task *types.Task, artifactID string) (*types.Artifact, bool)
- func (ah *ArtifactHelper) GetArtifactCount(task *types.Task) int
- func (ah *ArtifactHelper) GetArtifactSummary(task *types.Task) map[string]int
- func (ah *ArtifactHelper) GetArtifactsByType(task *types.Task, partKind string) []types.Artifact
- func (ah *ArtifactHelper) GetDataArtifacts(task *types.Task) []types.Artifact
- func (ah *ArtifactHelper) GetFileArtifacts(task *types.Task) []types.Artifact
- func (ah *ArtifactHelper) GetTextArtifacts(task *types.Task) []types.Artifact
- func (ah *ArtifactHelper) HasArtifacts(task *types.Task) bool
- type Client
- func (c *Client) CancelTask(ctx context.Context, params types.TaskIdParams) (*types.JSONRPCSuccessResponse, error)
- func (c *Client) GetAgentCard(ctx context.Context) (*types.AgentCard, error)
- func (c *Client) GetArtifactHelper() *ArtifactHelper
- func (c *Client) GetBaseURL() string
- func (c *Client) GetConfig() Config
- func (c *Client) GetHealth(ctx context.Context) (*HealthResponse, error)
- func (c *Client) GetLogger() *zap.Logger
- func (c *Client) GetTask(ctx context.Context, params types.TaskQueryParams) (*types.JSONRPCSuccessResponse, error)
- func (c *Client) ListTasks(ctx context.Context, params types.TaskListParams) (*types.JSONRPCSuccessResponse, error)
- func (c *Client) RemoveHeader(key string)
- func (c *Client) SendTask(ctx context.Context, params types.MessageSendParams) (*types.JSONRPCSuccessResponse, error)
- func (c *Client) SendTaskStreaming(ctx context.Context, params types.MessageSendParams) (<-chan types.JSONRPCSuccessResponse, error)
- func (c *Client) SetHTTPClient(client *http.Client)
- func (c *Client) SetHeader(key, value string)
- func (c *Client) SetLogger(logger *zap.Logger)
- func (c *Client) SetMaxRetries(maxRetries int)
- func (c *Client) SetRetryDelay(delay time.Duration)
- func (c *Client) SetTimeout(timeout time.Duration)
- type Config
- type DownloadConfig
- type DownloadResult
- type FileData
- type HealthResponse
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) (<-chan types.JSONRPCSuccessResponse, 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
// Artifact utilities
GetArtifactHelper() *ArtifactHelper
}
A2AClient defines the interface for an A2A protocol client
func NewClientWithConfig ¶
NewClientWithConfig creates a new A2A client with custom configuration
type ArtifactHelper ¶ added in v0.10.0
type ArtifactHelper struct{}
ArtifactHelper provides utility functions for working with artifacts in client responses
func NewArtifactHelper ¶ added in v0.10.0
func NewArtifactHelper() *ArtifactHelper
NewArtifactHelper creates a new client-side artifact helper instance
func (*ArtifactHelper) DownloadAllArtifacts ¶ added in v0.13.1
func (ah *ArtifactHelper) DownloadAllArtifacts(ctx context.Context, task *types.Task, config *DownloadConfig) ([]*DownloadResult, error)
DownloadAllArtifacts downloads all files from all artifacts in a task
func (*ArtifactHelper) DownloadArtifact ¶ added in v0.13.1
func (ah *ArtifactHelper) DownloadArtifact(ctx context.Context, artifact *types.Artifact, config *DownloadConfig) ([]*DownloadResult, error)
DownloadArtifact downloads all files from an artifact
func (*ArtifactHelper) DownloadFileData ¶ added in v0.13.1
func (ah *ArtifactHelper) DownloadFileData(ctx context.Context, fileData FileData, config *DownloadConfig) (*DownloadResult, error)
DownloadFileData downloads a FileData object to disk
func (*ArtifactHelper) ExtractArtifactUpdateFromStreamEvent ¶ added in v0.10.0
func (ah *ArtifactHelper) ExtractArtifactUpdateFromStreamEvent(eventData any) (*types.TaskArtifactUpdateEvent, bool)
ExtractArtifactUpdateFromStreamEvent extracts an artifact update event from a streaming event
func (*ArtifactHelper) ExtractArtifactsFromTask ¶ added in v0.10.0
func (ah *ArtifactHelper) ExtractArtifactsFromTask(task *types.Task) []types.Artifact
ExtractArtifactsFromTask extracts all artifacts from a task
func (*ArtifactHelper) ExtractDataFromArtifact ¶ added in v0.10.0
func (ah *ArtifactHelper) ExtractDataFromArtifact(artifact *types.Artifact) []map[string]any
ExtractDataFromArtifact extracts structured data from an artifact
func (*ArtifactHelper) ExtractFileDataFromArtifact ¶ added in v0.10.0
func (ah *ArtifactHelper) ExtractFileDataFromArtifact(artifact *types.Artifact) ([]FileData, error)
ExtractFileDataFromArtifact extracts file data from an artifact
func (*ArtifactHelper) ExtractTaskFromResponse ¶ added in v0.10.0
func (ah *ArtifactHelper) ExtractTaskFromResponse(response *types.JSONRPCSuccessResponse) (*types.Task, error)
ExtractTaskFromResponse extracts a task from a JSON-RPC response
func (*ArtifactHelper) ExtractTextFromArtifact ¶ added in v0.10.0
func (ah *ArtifactHelper) ExtractTextFromArtifact(artifact *types.Artifact) []string
ExtractTextFromArtifact extracts all text content from an artifact
func (*ArtifactHelper) FilterArtifactsByName ¶ added in v0.10.0
func (ah *ArtifactHelper) FilterArtifactsByName(task *types.Task, namePattern string) []types.Artifact
FilterArtifactsByName returns artifacts that match a name pattern (case-insensitive)
func (*ArtifactHelper) GetArtifactByID ¶ added in v0.10.0
func (ah *ArtifactHelper) GetArtifactByID(task *types.Task, artifactID string) (*types.Artifact, bool)
GetArtifactByID retrieves a specific artifact by its ID from a task
func (*ArtifactHelper) GetArtifactCount ¶ added in v0.10.0
func (ah *ArtifactHelper) GetArtifactCount(task *types.Task) int
GetArtifactCount returns the number of artifacts in a task
func (*ArtifactHelper) GetArtifactSummary ¶ added in v0.10.0
func (ah *ArtifactHelper) GetArtifactSummary(task *types.Task) map[string]int
GetArtifactSummary returns a summary of artifacts by type
func (*ArtifactHelper) GetArtifactsByType ¶ added in v0.10.0
GetArtifactsByType retrieves all artifacts containing parts of a specific type
func (*ArtifactHelper) GetDataArtifacts ¶ added in v0.10.0
func (ah *ArtifactHelper) GetDataArtifacts(task *types.Task) []types.Artifact
GetDataArtifacts retrieves all artifacts that contain data parts
func (*ArtifactHelper) GetFileArtifacts ¶ added in v0.10.0
func (ah *ArtifactHelper) GetFileArtifacts(task *types.Task) []types.Artifact
GetFileArtifacts retrieves all artifacts that contain file parts
func (*ArtifactHelper) GetTextArtifacts ¶ added in v0.10.0
func (ah *ArtifactHelper) GetTextArtifacts(task *types.Task) []types.Artifact
GetTextArtifacts retrieves all artifacts that contain text parts
func (*ArtifactHelper) HasArtifacts ¶ added in v0.10.0
func (ah *ArtifactHelper) HasArtifacts(task *types.Task) bool
HasArtifacts returns true if the task contains any artifacts
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 ¶
GetAgentCard retrieves the agent card information via HTTP GET to .well-known/agent-card.json
func (*Client) GetArtifactHelper ¶ added in v0.10.0
func (c *Client) GetArtifactHelper() *ArtifactHelper
GetArtifactHelper returns the artifact helper for extracting artifacts from responses
func (*Client) GetBaseURL ¶
GetBaseURL returns the base URL of the client
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) GetTask ¶
func (c *Client) GetTask(ctx context.Context, params types.TaskQueryParams) (*types.JSONRPCSuccessResponse, error)
GetTaskWithContext retrieves the status of a task with context support
func (*Client) ListTasks ¶
func (c *Client) ListTasks(ctx context.Context, params types.TaskListParams) (*types.JSONRPCSuccessResponse, error)
ListTasks retrieves a list of tasks from the agent
func (*Client) RemoveHeader ¶
RemoveHeader removes a custom header
func (*Client) SendTask ¶
func (c *Client) SendTask(ctx context.Context, params types.MessageSendParams) (*types.JSONRPCSuccessResponse, error)
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) (<-chan types.JSONRPCSuccessResponse, error)
SendTaskStreaming sends a task and returns a channel for streaming events
func (*Client) SetHTTPClient ¶
SetHTTPClient allows customizing the HTTP client
func (*Client) SetMaxRetries ¶
SetMaxRetries sets the maximum number of retry attempts
func (*Client) SetRetryDelay ¶
SetRetryDelay sets the delay between retry attempts
func (*Client) SetTimeout ¶
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 ¶
DefaultConfig returns a default configuration
type DownloadConfig ¶ added in v0.13.1
type DownloadConfig struct {
// OutputDir is the directory where files will be saved (default: current directory)
OutputDir string
// HTTPClient is the HTTP client to use for downloads (default: http.DefaultClient)
HTTPClient *http.Client
// OverwriteExisting allows overwriting existing files (default: false)
OverwriteExisting bool
// OrganizeByArtifactID creates subdirectories by artifact ID to prevent collisions (default: true)
OrganizeByArtifactID bool
}
DownloadConfig holds configuration for downloading artifacts
type DownloadResult ¶ added in v0.13.1
type DownloadResult struct {
// FileName is the name of the downloaded file
FileName string
// FilePath is the full path where the file was saved
FilePath string
// BytesWritten is the number of bytes written to disk
BytesWritten int64
// Error contains any error that occurred during download
Error error
}
DownloadResult represents the result of a file download
type FileData ¶ added in v0.10.0
FileData represents extracted file information from an artifact
func (*FileData) GetFileName ¶ added in v0.10.0
GetFileName returns the file name or a default if none is set
func (*FileData) GetMIMEType ¶ added in v0.10.0
GetMIMEType returns the MIME type or a default if none is set
func (*FileData) IsDataFile ¶ added in v0.10.0
IsDataFile returns true if this file contains data (bytes), false if it's URI-based
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
}
HealthResponse represents the response from the health endpoint