Documentation
¶
Overview ¶
Package a2a provides an Agent-to-Agent Protocol (A2A) v1.0 plugin for Crush. It exposes Crush as an A2A server and provides client tools for invoking remote A2A agents. This plugin uses the official github.com/a2aproject/a2a-go/v2 SDK.
Index ¶
- Constants
- func ExtractText(msg *a2a.Message) string
- func ExtractTextFromParts(parts a2a.ContentParts) string
- func ResetManager()
- type A2AServerConfig
- type AttachFileParams
- type Client
- func (c *Client) CancelTask(ctx context.Context, taskID a2acore.TaskID) (*a2acore.Task, error)
- func (c *Client) Close() error
- func (c *Client) FetchAgentCard(ctx context.Context) (*a2acore.AgentCard, error)
- func (c *Client) GetTask(ctx context.Context, taskID a2acore.TaskID) (*a2acore.Task, error)
- func (c *Client) LastContextID() string
- func (c *Client) SendMessage(ctx context.Context, msg *a2acore.Message) (a2acore.SendMessageResult, error)
- func (c *Client) SendMessageWithContext(ctx context.Context, text, contextID string) (a2acore.SendMessageResult, error)
- func (c *Client) SendStreamingMessage(ctx context.Context, msg *a2acore.Message) (iter.Seq2[a2acore.Event, error], error)
- func (c *Client) SetContextID(id string)
- type ClientOption
- type Config
- type GetTaskParams
- type ListAgentsParams
- type SendMessageParams
- type ServerConfig
- type ServerHook
- func (h *ServerHook) Addr() string
- func (h *ServerHook) ArtifactStore() *artifactStore
- func (h *ServerHook) CurrentTaskID() a2acore.TaskID
- func (h *ServerHook) Name() string
- func (h *ServerHook) Ready() <-chan struct{}
- func (h *ServerHook) Start(ctx context.Context) error
- func (h *ServerHook) Stop() error
- type SkillConfig
Constants ¶
const ( CleanupInterval = 5 * time.Minute ArtifactTTL = 1 * time.Hour )
const ( ToolListAgents = "a2a_list_agents" ToolSendMessage = "a2a_send_message" ToolGetTask = "a2a_get_task" ToolAttachFile = "a2a_attach_file" DescriptionListAgents = `` /* 455-byte string literal not displayed */ DescriptionSendMessage = `` /* 610-byte string literal not displayed */ DescriptionGetTask = `` /* 306-byte string literal not displayed */ DescriptionAttachFile = `` /* 571-byte string literal not displayed */ )
const ( PluginName = "a2a" HookName = "a2a-server" DefaultPort = 8200 DefaultAgentName = "crush" )
Variables ¶
This section is empty.
Functions ¶
func ExtractText ¶
func ExtractTextFromParts ¶
func ExtractTextFromParts(parts a2a.ContentParts) string
Types ¶
type A2AServerConfig ¶
type A2AServerConfig struct {
Port int `json:"port,omitempty"`
AgentName string `json:"agent_name,omitempty"`
Description string `json:"description,omitempty"`
Skills []SkillConfig `json:"skills,omitempty"`
}
A2AServerConfig is the server-side configuration for exposing Crush as an A2A agent. Configured in crush.json under options.plugins.a2a-server
type AttachFileParams ¶
type AttachFileParams struct {
FilePath string `json:"file_path" jsonschema:"description=Path to the file to attach."`
Name string `json:"name,omitempty" jsonschema:"description=Human-readable name for the artifact."`
Description string `json:"description,omitempty" jsonschema:"description=Description of the artifact."`
MediaType string `json:"media_type,omitempty" jsonschema:"description=MIME type. Auto-detected from extension if omitted."`
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the official A2A SDK client with connection caching.
func NewClient ¶
func NewClient(baseURL string, opts ...ClientOption) *Client
NewClient creates a new A2A client for the given base URL.
func (*Client) CancelTask ¶
CancelTask cancels a task by ID.
func (*Client) FetchAgentCard ¶
FetchAgentCard fetches the agent card from /.well-known/agent-card.json.
func (*Client) LastContextID ¶
LastContextID returns the last contextId received from this server.
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, msg *a2acore.Message) (a2acore.SendMessageResult, error)
SendMessage sends a message to the remote A2A agent.
func (*Client) SendMessageWithContext ¶
func (c *Client) SendMessageWithContext(ctx context.Context, text, contextID string) (a2acore.SendMessageResult, error)
SendMessageWithContext sends a text message with an existing contextID for multi-turn conversations.
func (*Client) SendStreamingMessage ¶
func (c *Client) SendStreamingMessage(ctx context.Context, msg *a2acore.Message) (iter.Seq2[a2acore.Event, error], error)
SendStreamingMessage sends a message and returns a streaming iterator.
func (*Client) SetContextID ¶
SetContextID stores a contextId for auto-propagation in subsequent messages.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption configures a Client.
func WithHeaders ¶
func WithHeaders(h map[string]string) ClientOption
WithHeaders sets custom headers for requests.
type Config ¶
type Config struct {
Servers []ServerConfig `json:"servers,omitempty"`
DefaultTimeoutSeconds int `json:"default_timeout_seconds,omitempty"`
}
Config is the client-side configuration for connecting to remote A2A servers. Configured in crush.json under options.plugins.a2a
type GetTaskParams ¶
type ListAgentsParams ¶
type ListAgentsParams struct {
Server string `` /* 126-byte string literal not displayed */
}
type SendMessageParams ¶
type SendMessageParams struct {
Input string `json:"input" jsonschema:"description=Text message to send to the agent."`
Server string `json:"server,omitempty" jsonschema:"description=Name of the A2A server. Uses the first configured server if omitted."`
ContextID string `json:"context_id,omitempty" jsonschema:"description=Context ID from a previous response for multi-turn conversations."`
Streaming bool `json:"streaming,omitempty" jsonschema:"description=If true use SendStreamingMessage for SSE streaming."`
}
type ServerConfig ¶
type ServerConfig struct {
Name string `json:"name"`
URL string `json:"url"`
Headers map[string]string `json:"headers,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
ServerConfig defines a single remote A2A server endpoint.
func (ServerConfig) IsEnabled ¶
func (s ServerConfig) IsEnabled() bool
type ServerHook ¶
type ServerHook struct {
// contains filtered or unexported fields
}
ServerHook implements plugin.Hook to run an A2A v1.0 server alongside Crush.
func NewServerHook ¶
func NewServerHook(app *plugin.App, cfg A2AServerConfig) (*ServerHook, error)
NewServerHook creates a new A2A server hook.
func (*ServerHook) Addr ¶
func (h *ServerHook) Addr() string
func (*ServerHook) ArtifactStore ¶
func (h *ServerHook) ArtifactStore() *artifactStore
ArtifactStore returns the artifact store for use by the attach_file tool.
func (*ServerHook) CurrentTaskID ¶
func (h *ServerHook) CurrentTaskID() a2acore.TaskID
CurrentTaskID returns the task ID of the currently executing task.
func (*ServerHook) Name ¶
func (h *ServerHook) Name() string
func (*ServerHook) Ready ¶
func (h *ServerHook) Ready() <-chan struct{}
func (*ServerHook) Stop ¶
func (h *ServerHook) Stop() error