a2a

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package a2a provides experimental functionality for µ-agent.

WARNING: This package is experimental and subject to change. The API may change or be removed in future versions without notice. Use at your own risk in production environments. NOTE: This is a partial implementation of the A2A protocol. IMPORTANT: This is a work in progress and may not cover all aspects of the A2A protocol.

Package a2a provides experimental functionality for µ-agent.

WARNING: This package is experimental and subject to change. The API may change or be removed in future versions without notice. Use at your own risk in production environments. NOTE: This is a partial implementation of the A2A protocol. IMPORTANT: This is a work in progress and may not cover all aspects of the A2A protocol.

Package a2a provides experimental functionality for µ-agent.

WARNING: This package is experimental and subject to change. The API may change or be removed in future versions without notice. Use at your own risk in production environments. NOTE: This is a partial implementation of the A2A protocol. IMPORTANT: This is a work in progress and may not cover all aspects of the A2A protocol.

Package a2a provides experimental functionality for µ-agent.

WARNING: This package is experimental and subject to change. The API may change or be removed in future versions without notice. Use at your own risk in production environments. NOTE: This is a partial implementation of the A2A protocol. IMPORTANT: This is a work in progress and may not cover all aspects of the A2A protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentCardToJSONString

func AgentCardToJSONString(agentCard AgentCard) (string, error)

func TaskRequestToJSONString

func TaskRequestToJSONString(taskRequest TaskRequest) (string, error)

func TaskResponseToJSONString

func TaskResponseToJSONString(taskResponse TaskResponse) (string, error)

Types

type A2AClient

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

func NewA2AClient

func NewA2AClient(agentBaseURL string) *A2AClient

func (*A2AClient) PingAgent

func (a2acli *A2AClient) PingAgent() (AgentCard, error)

func (*A2AClient) SendToAgent

func (a2acli *A2AClient) SendToAgent(taskRequest TaskRequest) (TaskResponse, error)

func (*A2AClient) SendToAgentStream added in v0.0.1

func (a2acli *A2AClient) SendToAgentStream(taskRequest TaskRequest, streamCallback func(content string) error) (TaskResponse, error)

SendToAgentStream sends a task request to the agent and streams the response streamCallback is called for each chunk of content received Returns the complete response and any error

type A2AServer

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

func NewA2AServer

func NewA2AServer(port int, agentCard AgentCard, agentCallback func(taskRequest TaskRequest) (TaskResponse, error)) *A2AServer

NewA2AServer creates a new A2A server with the given parameters

func NewA2AServerWithStreaming added in v0.0.1

func NewA2AServerWithStreaming(port int, agentCard AgentCard, agentStreamCallback func(taskRequest TaskRequest, streamFunc func(content string) error) error) *A2AServer

NewA2AServerWithStreaming creates a new A2A server with streaming support

func (*A2AServer) Start

func (a2asvr *A2AServer) Start() error

type AgentCard

type AgentCard struct {
	Name         string           `json:"name"`
	Description  string           `json:"description"`
	URL          string           `json:"url"`
	Version      string           `json:"version"`
	Capabilities map[string]any   `json:"capabilities"`
	Skills       []map[string]any `json:"skills,omitempty"` // Optional, for storing skills related to the agent
}

AgentCard represents the metadata for this agent

type AgentMessage

type AgentMessage struct {
	Role      string     `json:"role,omitempty"`
	Parts     []TextPart `json:"parts"`
	MessageID string     `json:"messageId,omitempty"` // Optional, for storing message ID
	TaskID    string     `json:"taskId,omitempty"`    // Optional, for storing task ID
	ContextID string     `json:"contextId,omitempty"` // Optional, for storing context ID
}

Message represents a message structure

type AgentMessageParams

type AgentMessageParams struct {
	Message  AgentMessage   `json:"message"`
	MetaData map[string]any `json:"metadata,omitempty"` // Optional, for additional metadata
}

type Artifact

type Artifact struct {
	ArtifactID string     `json:"artifactId"`
	Name       string     `json:"name"`
	Parts      []TextPart `json:"parts"` // Parts of the artifact, e.g., text, images, etc.
}

type Result

type Result struct {
	ID        string         `json:"id"`
	ContextID string         `json:"contextId"`
	Status    TaskStatus     `json:"status"`
	Artifacts []Artifact     `json:"artifacts,omitempty"` // Optional, for storing artifacts related to the task
	History   []AgentMessage `json:"history,omitempty"`   // Optional, for storing message history related to the task
	Kind      string         `json:"kind"`                // Should be "task"
	Metadata  map[string]any `json:"metadata,omitempty"`  // Optional, for additional metadata
}

type TaskRequest

type TaskRequest struct {
	JSONRpcVersion string             `json:"jsonrpc"` // Should be "2.0"
	ID             string             `json:"id"`
	Params         AgentMessageParams `json:"params"`
	Method         string             `json:"method,omitempty"` // Optional, for specifying the method of the task
}

REF: https://google-a2a.github.io/A2A/specification/#92-basic-execution-synchronous-polling-style TaskRequest represents an incoming A2A task request

type TaskResponse

type TaskResponse struct {
	JSONRpcVersion string `json:"jsonrpc"` // Should be "2.0"
	ID             string `json:"id"`
	Result         Result `json:"result"` // The result of the task execution

}

TaskResponse represents the response task structure

type TaskStatus

type TaskStatus struct {
	State string `json:"state"`
}

TaskStatus represents the status of a task

type TextPart

type TextPart struct {
	Text string `json:"text"`
	Type string `json:"type"` // Should be "text" for text parts
}

TextPart represents a text part of a message

Jump to

Keyboard shortcuts

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