client

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package client implements the non-streaming A2A 1.0 JSON-RPC client.

Index

Constants

View Source
const (
	MethodSendMessage          = wire.MethodSendMessage
	MethodSendStreamingMessage = wire.MethodSendStreamingMessage
	MethodGetTask              = wire.MethodGetTask
	MethodListTasks            = wire.MethodListTasks
	MethodCancelTask           = wire.MethodCancelTask
	MethodSubscribeToTask      = wire.MethodSubscribeToTask
)
View Source
const (
	StateSubmitted     = wire.StateSubmitted
	StateWorking       = wire.StateWorking
	StateInputRequired = wire.StateInputRequired
	StateCompleted     = wire.StateCompleted
	StateCanceled      = wire.StateCanceled
	StateFailed        = wire.StateFailed
	StateRejected      = wire.StateRejected
	StateAuthRequired  = wire.StateAuthRequired
)
View Source
const (
	RoleUser  = wire.RoleUser
	RoleAgent = wire.RoleAgent
)

Variables

This section is empty.

Functions

func IsInputRequired

func IsInputRequired(state string) bool

IsInputRequired reports whether state pauses a task for user input.

func IsTerminal

func IsTerminal(state string) bool

IsTerminal reports whether state ends a task.

func NormalizeState

func NormalizeState(state string) string

NormalizeState maps A2A 0.3 lowercase states and 1.0 enum values to the 1.0 wire form.

Types

type AgentCard

type AgentCard = wire.AgentCard

type CancelTaskRequest

type CancelTaskRequest = wire.CancelTaskRequest

type Client

type Client struct {
	Name     string
	Card     AgentCard
	Endpoint string
	// contains filtered or unexported fields
}

Client is a non-streaming A2A JSON-RPC client bound to one remote agent.

func Discover

func Discover(ctx context.Context, name, cardURL, token string, httpClient *http.Client) (*Client, error)

Discover fetches an Agent Card and resolves its JSON-RPC endpoint. An empty path on cardURL is treated as a base URL and gets the well-known card path appended.

func (*Client) Answer

func (c *Client) Answer(task *Task) string

Answer extracts the textual result of a finished task.

func (*Client) CancelTask

func (c *Client) CancelTask(ctx context.Context, taskID string) (*Task, error)

CancelTask requests cancellation of a running task.

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, taskID string) (*Task, error)

GetTask fetches the current task state.

func (*Client) Options

func (c *Client) Options(task *Task) []string

Options returns the choices attached to an input-required task, when present.

func (*Client) Question

func (c *Client) Question(task *Task) string

Question returns the prompt attached to an input-required task.

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, text, contextID, taskID string) (*Task, *Message, error)

SendMessage sends a text message. When taskID is set the message resumes that task; otherwise a new task is started. The result is either a Task to poll or a direct Message when the remote agent answers synchronously.

func (*Client) WaitTask

func (c *Client) WaitTask(ctx context.Context, taskID string, interval time.Duration) (*Task, error)

WaitTask polls until the task completes, fails, is canceled, or asks for input. Transient lookup errors are retried a few times before giving up.

type GetTaskRequest

type GetTaskRequest = wire.GetTaskRequest

type Message

type Message = wire.Message

type Part

type Part = wire.Part

type RPCError

type RPCError = wire.RPCError

type Request

type Request = wire.Request

type SendMessageRequest

type SendMessageRequest = wire.SendMessageRequest

type Task

type Task = wire.Task

type TaskStatus

type TaskStatus = wire.TaskStatus

Jump to

Keyboard shortcuts

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