Documentation
¶
Overview ¶
Package a2a provides conversion utilities between A2A protocol data structures and ADK core data structures. These converters handle the transformation of messages, parts, and content between the two formats, ensuring compatibility and proper data mapping.
The conversion functions support: - Text content (bidirectional) - File content (with metadata preservation) - Function calls (represented as text in A2A) - Data parts (with structured metadata)
Usage:
// Convert A2A message to core content content := a2a.ConvertA2AMessageToContent(a2aMessage) // Convert core content to A2A message message := a2a.ConvertCoreContentToA2AMessage(content, "unique-message-id") // Extract simple text from parts text := a2a.ExtractTextFromA2AParts(parts)
Index ¶
- func ConvertA2AArtifactToContent(artifact *Artifact) *core.Content
- func ConvertA2AMessageToContent(message *Message) *core.Content
- func ConvertA2APartToCorePart(a2aPart Part) *core.Part
- func ConvertA2APartsToCoreParts(a2aParts []Part) []core.Part
- func ConvertA2ATaskStatusToContent(status *TaskStatus) *core.Content
- func CreateSimpleTextCoreContent(role, text string) *core.Content
- func ExtractTextFromA2AParts(parts []Part) string
- func ExtractTextFromCoreParts(parts []core.Part) string
- type AgentAuthentication
- type AgentCapabilities
- type AgentCard
- type AgentCardResolver
- type AgentProvider
- type AgentSkill
- type Artifact
- type CancelTaskRequest
- type CancelTaskResponse
- type Client
- func (c *Client) CancelTask(ctx context.Context, params *TaskIdParams) (*Task, error)
- func (c *Client) Close() error
- func (c *Client) GetTask(ctx context.Context, params *TaskQueryParams) (*Task, error)
- func (c *Client) GetTaskPushNotification(ctx context.Context, params *TaskIdParams) (*TaskPushNotificationConfig, error)
- func (c *Client) SendMessage(ctx context.Context, params *MessageSendParams) (*Task, error)
- func (c *Client) SendMessageStream(ctx context.Context, params *MessageSendParams, ...) error
- func (c *Client) SendTask(ctx context.Context, params *TaskSendParams) (*Task, error)
- func (c *Client) SendTaskStream(ctx context.Context, params *TaskSendParams, ...) error
- func (c *Client) SetTaskPushNotification(ctx context.Context, config *TaskPushNotificationConfig) (*TaskPushNotificationConfig, error)
- type ClientConfig
- type DataPart
- type FileContent
- type FilePart
- type GetAgentCardRequest
- type GetAgentCardResponse
- type GetTaskPushNotificationRequest
- type GetTaskPushNotificationResponse
- type GetTaskRequest
- type GetTaskResponse
- type InternalError
- type InvalidParamsError
- type InvalidRequestError
- type JSONParseError
- type JSONRPCError
- type JSONRPCMessage
- type JSONRPCRequest
- type JSONRPCResponse
- type Message
- type MessageSendConfiguration
- type MessageSendParams
- type MethodNotFoundError
- type Part
- type PushNotificationAuthenticationInfo
- type PushNotificationConfig
- type PushNotificationNotSupportedError
- type SendMessageRequest
- type SendMessageResponse
- type SendMessageResponseResult
- type SendStreamingMessageRequest
- type SendStreamingMessageResponse
- type SendStreamingMessageResponseResult
- type SendTaskRequest
- type SendTaskResponse
- type SendTaskStreamingRequest
- type SendTaskStreamingResponse
- type SetTaskPushNotificationRequest
- type SetTaskPushNotificationResponse
- type Task
- type TaskArtifactUpdateEvent
- type TaskIdParams
- type TaskNotCancelableError
- type TaskNotFoundError
- type TaskPushNotificationConfig
- type TaskQueryParams
- type TaskResubscriptionRequest
- type TaskSendParams
- type TaskState
- type TaskStatus
- type TaskStatusUpdateEvent
- type TextPart
- type UnsupportedOperationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertA2AArtifactToContent ¶
ConvertA2AArtifactToContent converts A2A artifact to ADK content
func ConvertA2AMessageToContent ¶
ConvertA2AMessageToContent converts an A2A message to ADK content
func ConvertA2APartToCorePart ¶
ConvertA2APartToCorePart converts a single A2A part to an ADK core part
func ConvertA2APartsToCoreParts ¶
ConvertA2APartsToCoreParts converts A2A parts to ADK core parts
func ConvertA2ATaskStatusToContent ¶
func ConvertA2ATaskStatusToContent(status *TaskStatus) *core.Content
ConvertA2ATaskStatusToContent converts A2A task status message to ADK content
func CreateSimpleTextCoreContent ¶
CreateSimpleTextCoreContent creates a simple core content with text
func ExtractTextFromA2AParts ¶
ExtractTextFromA2AParts extracts text content from A2A parts for simple use cases
func ExtractTextFromCoreParts ¶
ExtractTextFromCoreParts extracts text content from core parts for simple use cases
Types ¶
type AgentAuthentication ¶
type AgentAuthentication struct { Schemes []string `json:"schemes"` Credentials *string `json:"credentials,omitempty"` }
AgentAuthentication defines authentication details for an agent.
type AgentCapabilities ¶
type AgentCapabilities struct { Streaming bool `json:"streaming,omitempty"` PushNotifications bool `json:"pushNotifications,omitempty"` StateTransitionHistory bool `json:"stateTransitionHistory,omitempty"` }
AgentCapabilities defines the capabilities of an agent.
type AgentCard ¶
type AgentCard struct { Name string `json:"name"` Description *string `json:"description,omitempty"` URL string `json:"url"` Provider *AgentProvider `json:"provider,omitempty"` Version string `json:"version"` DocumentationURL *string `json:"documentationUrl,omitempty"` Capabilities AgentCapabilities `json:"capabilities"` Authentication *AgentAuthentication `json:"authentication,omitempty"` DefaultInputModes []string `json:"defaultInputModes,omitempty"` DefaultOutputModes []string `json:"defaultOutputModes,omitempty"` Skills []AgentSkill `json:"skills"` }
AgentCard provides metadata about an agent.
type AgentCardResolver ¶
type AgentCardResolver struct {
// contains filtered or unexported fields
}
AgentCardResolver helps resolve agent cards from URLs
func NewAgentCardResolver ¶
func NewAgentCardResolver(baseURL string, httpClient *http.Client) *AgentCardResolver
NewAgentCardResolver creates a new agent card resolver
func (*AgentCardResolver) GetAgentCard ¶
func (r *AgentCardResolver) GetAgentCard(ctx context.Context, relativePath string) (*AgentCard, error)
GetAgentCard fetches an agent card from a relative path
func (*AgentCardResolver) GetWellKnownAgentCard ¶
func (r *AgentCardResolver) GetWellKnownAgentCard(ctx context.Context) (*AgentCard, error)
GetWellKnownAgentCard fetches the agent card from /.well-known/agent.json
type AgentProvider ¶
type AgentProvider struct { Organization string `json:"organization"` URL *string `json:"url,omitempty"` }
AgentProvider provides information about the agent's provider.
type AgentSkill ¶
type AgentSkill struct { ID string `json:"id"` Name string `json:"name"` Description *string `json:"description,omitempty"` Tags []string `json:"tags,omitempty"` Examples []string `json:"examples,omitempty"` InputModes []string `json:"inputModes,omitempty"` OutputModes []string `json:"outputModes,omitempty"` }
AgentSkill describes a specific skill or capability of the agent.
type Artifact ¶
type Artifact struct { ArtifactId string `json:"artifactId"` Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` Parts []Part `json:"parts"` // Part is a union type, using any or specific struct with Type field Metadata map[string]any `json:"metadata,omitempty"` Extensions []string `json:"extensions,omitempty"` }
Artifact represents a piece of data generated or used by a task.
type CancelTaskRequest ¶
type CancelTaskRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "tasks/cancel" Params TaskIdParams `json:"params"` }
CancelTaskRequest is a JSON-RPC request to cancel a task.
type CancelTaskResponse ¶
type CancelTaskResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result *Task `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` }
CancelTaskResponse is a JSON-RPC response for a cancel task request.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an A2A client for communicating with remote agents
func NewClient ¶
func NewClient(agentCard *AgentCard, config *ClientConfig) (*Client, error)
NewClient creates a new A2A client
func (*Client) CancelTask ¶
CancelTask cancels a task by ID
func (*Client) GetTaskPushNotification ¶
func (c *Client) GetTaskPushNotification(ctx context.Context, params *TaskIdParams) (*TaskPushNotificationConfig, error)
GetTaskPushNotification gets push notification config for a task
func (*Client) SendMessage ¶
SendMessage sends a message to the remote agent using A2A-compliant "message/send" method
func (*Client) SendMessageStream ¶
func (c *Client) SendMessageStream(ctx context.Context, params *MessageSendParams, eventHandler func(*SendStreamingMessageResponse) error) error
SendMessageStream sends a message and subscribes to streaming updates using A2A-compliant "message/stream" method
func (*Client) SendTask ¶
SendTask is a legacy method that wraps the new A2A-compliant SendMessage method DEPRECATED: Use SendMessage with MessageSendParams instead
func (*Client) SendTaskStream ¶
func (c *Client) SendTaskStream(ctx context.Context, params *TaskSendParams, eventHandler func(*SendTaskStreamingResponse) error) error
SendTaskStream is a legacy method that wraps the new A2A-compliant SendMessageStream method DEPRECATED: Use SendMessageStream with MessageSendParams instead
func (*Client) SetTaskPushNotification ¶
func (c *Client) SetTaskPushNotification(ctx context.Context, config *TaskPushNotificationConfig) (*TaskPushNotificationConfig, error)
SetTaskPushNotification sets push notification config for a task
type ClientConfig ¶
type ClientConfig struct { // Timeout for HTTP requests Timeout time.Duration // Custom HTTP client (optional) HTTPClient *http.Client // Base URL for the A2A server BaseURL string // Additional headers to include in requests Headers map[string]string }
ClientConfig holds configuration for the A2A client
func DefaultClientConfig ¶
func DefaultClientConfig() *ClientConfig
DefaultClientConfig returns a default client configuration
type DataPart ¶
type DataPart struct { Type string `json:"type"` // "data" Data map[string]any `json:"data"` Metadata map[string]any `json:"metadata,omitempty"` }
DataPart represents a structured data part of a message or artifact.
type FileContent ¶
type FileContent struct { Name *string `json:"name,omitempty"` MimeType *string `json:"mimeType,omitempty"` Bytes *string `json:"bytes,omitempty"` // Base64 encoded content URI *string `json:"uri,omitempty"` }
FileContent represents the content of a file, either inline or via URI.
func (*FileContent) Validate ¶
func (fc *FileContent) Validate() error
Validate ensures that FileContent has either Bytes or URI but not both
type FilePart ¶
type FilePart struct { Type string `json:"type"` // "file" File FileContent `json:"file"` Metadata map[string]any `json:"metadata,omitempty"` }
FilePart represents a file part of a message or artifact.
type GetAgentCardRequest ¶
type GetAgentCardRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "agents/card" Params any `json:"params,omitempty"` // Usually empty for agent's own card }
GetAgentCardRequest represents a request to get an agent card.
type GetAgentCardResponse ¶
type GetAgentCardResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result *AgentCard `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` }
GetAgentCardResponse represents the response containing an agent card.
type GetTaskPushNotificationRequest ¶
type GetTaskPushNotificationRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "tasks/pushNotification/get" Params TaskIdParams `json:"params"` }
GetTaskPushNotificationRequest is a JSON-RPC request to get push notification config for a task.
type GetTaskPushNotificationResponse ¶
type GetTaskPushNotificationResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result *TaskPushNotificationConfig `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` }
GetTaskPushNotificationResponse is a JSON-RPC response for getting push notification config.
type GetTaskRequest ¶
type GetTaskRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "tasks/get" Params TaskQueryParams `json:"params"` }
GetTaskRequest is a JSON-RPC request to retrieve task details.
type GetTaskResponse ¶
type GetTaskResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result *Task `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` }
GetTaskResponse is a JSON-RPC response containing task details.
type InternalError ¶
type InternalError struct { Code int `json:"code"` // Should be -32603 Message string `json:"message"` // Should be "Internal error" Data any `json:"data,omitempty"` }
InternalError represents a generic internal JSON-RPC error.
func (*InternalError) Error ¶
func (e *InternalError) Error() string
Error implements the error interface for InternalError
type InvalidParamsError ¶
type InvalidParamsError struct { Code int `json:"code"` // Should be -32602 Message string `json:"message"` // Should be "Invalid parameters" Data any `json:"data,omitempty"` }
InvalidParamsError represents a JSON-RPC invalid parameters error.
func (*InvalidParamsError) Error ¶
func (e *InvalidParamsError) Error() string
Error implements the error interface for InvalidParamsError
type InvalidRequestError ¶
type InvalidRequestError struct { Code int `json:"code"` // Should be -32600 Message string `json:"message"` // Should be "Request payload validation error" Data any `json:"data,omitempty"` }
InvalidRequestError represents a JSON-RPC invalid request error.
func (*InvalidRequestError) Error ¶
func (e *InvalidRequestError) Error() string
Error implements the error interface for InvalidRequestError
type JSONParseError ¶
type JSONParseError struct { Code int `json:"code"` // Should be -32700 Message string `json:"message"` // Should be "Invalid JSON payload" Data any `json:"data,omitempty"` }
JSONParseError represents a JSON-RPC parse error.
func (*JSONParseError) Error ¶
func (e *JSONParseError) Error() string
Error implements the error interface for JSONParseError
type JSONRPCError ¶
type JSONRPCError struct { Code int `json:"code"` Message string `json:"message"` Data any `json:"data,omitempty"` }
JSONRPCError represents a standard JSON-RPC error object.
func (*JSONRPCError) Error ¶
func (e *JSONRPCError) Error() string
Error implements the error interface for JSONRPCError
type JSONRPCMessage ¶
type JSONRPCMessage struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id,omitempty"` }
JSONRPCMessage is a base structure for JSON-RPC messages.
type JSONRPCRequest ¶
type JSONRPCRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` Params any `json:"params,omitempty"` }
JSONRPCRequest is a base structure for JSON-RPC requests.
type JSONRPCResponse ¶
type JSONRPCResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result any `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` }
JSONRPCResponse is a base structure for JSON-RPC responses.
type Message ¶
type Message struct { Kind string `json:"kind"` // "message" MessageID string `json:"messageId"` // REQUIRED by A2A spec TaskID *string `json:"taskId,omitempty"` ContextID *string `json:"contextId,omitempty"` Role string `json:"role"` // "user" or "agent" Parts []Part `json:"parts"` // Part is a union type Metadata map[string]any `json:"metadata,omitempty"` Extensions []string `json:"extensions,omitempty"` ReferenceTaskIds []string `json:"referenceTaskIds,omitempty"` // List of task IDs this message references }
Message represents a single message in a task conversation.
func ConvertCoreContentToA2AMessage ¶
ConvertCoreContentToA2AMessage converts ADK content to an A2A message
func CreateSimpleTextA2AMessage ¶
CreateSimpleTextA2AMessage creates a simple A2A message with text content
type MessageSendConfiguration ¶
type MessageSendConfiguration struct { AcceptedOutputModes []string `json:"acceptedOutputModes"` // REQUIRED when present Blocking *bool `json:"blocking,omitempty"` HistoryLength *int `json:"historyLength,omitempty"` PushNotificationConfig *PushNotificationConfig `json:"pushNotificationConfig,omitempty"` }
MessageSendConfiguration represents optional configuration for message sending (A2A spec)
type MessageSendParams ¶
type MessageSendParams struct { Message Message `json:"message"` // REQUIRED Configuration *MessageSendConfiguration `json:"configuration,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` }
MessageSendParams represents parameters for message/send and message/stream methods (A2A spec)
type MethodNotFoundError ¶
type MethodNotFoundError struct { Code int `json:"code"` // Should be -32601 Message string `json:"message"` // Should be "Method not found" Data any `json:"data"` // Should be null }
MethodNotFoundError represents a JSON-RPC method not found error.
func (*MethodNotFoundError) Error ¶
func (e *MethodNotFoundError) Error() string
Error implements the error interface for MethodNotFoundError
type Part ¶
type Part struct { Type string `json:"type"` // "text", "file", or "data" Text *string `json:"text,omitempty"` File *FileContent `json:"file,omitempty"` Data map[string]any `json:"data,omitempty"` // For DataPart type Metadata map[string]any `json:"metadata,omitempty"` }
Part represents a component of a message or artifact. It's a union type (TextPart, FilePart, DataPart). Using a struct with a Type field and optional content fields is one way to model this. Custom UnmarshalJSON is often preferred for true union type handling.
func ConvertCorePartToA2APart ¶
ConvertCorePartToA2APart converts a single ADK core part to an A2A part
func ConvertCorePartsToA2AParts ¶
ConvertCorePartsToA2AParts converts ADK core parts to A2A parts
func (*Part) UnmarshalJSON ¶
UnmarshalJSON implements custom unmarshaling for Part to ensure data consistency
type PushNotificationAuthenticationInfo ¶
type PushNotificationAuthenticationInfo struct { Schemes []string `json:"schemes"` Credentials *string `json:"credentials,omitempty"` }
PushNotificationAuthenticationInfo holds authentication details.
type PushNotificationConfig ¶
type PushNotificationConfig struct { ID *string `json:"id"` URL string `json:"url"` Token *string `json:"token,omitempty"` Authentication *PushNotificationAuthenticationInfo `json:"authentication,omitempty"` }
PushNotificationConfig defines the configuration for push notifications.
type PushNotificationNotSupportedError ¶
type PushNotificationNotSupportedError struct { Code int `json:"code"` // Should be -32003 Message string `json:"message"` // Should be "Push Notification is not supported" Data any `json:"data"` // Should be null }
PushNotificationNotSupportedError indicates push notifications are not supported.
func (*PushNotificationNotSupportedError) Error ¶
func (e *PushNotificationNotSupportedError) Error() string
Error implements the error interface for PushNotificationNotSupportedError
type SendMessageRequest ¶
type SendMessageRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "message/send" Params MessageSendParams `json:"params"` }
SendMessageRequest represents the "message/send" JSON-RPC request (A2A compliant)
type SendMessageResponse ¶
type SendMessageResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result any `json:"result,omitempty"` // SendMessageResponseResult Error *JSONRPCError `json:"error,omitempty"` }
SendMessageResponse represents response from "message/send"
type SendStreamingMessageRequest ¶
type SendStreamingMessageRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "message/stream" Params MessageSendParams `json:"params"` // Same as SendMessageRequest }
SendStreamingMessageRequest represents the "message/stream" JSON-RPC request (A2A compliant)
type SendStreamingMessageResponse ¶
type SendStreamingMessageResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result any `json:"result,omitempty"` // SendStreamingMessageResponseResult Error *JSONRPCError `json:"error,omitempty"` Final *bool `json:"final,omitempty"` // Indicates final event in stream }
SendStreamingMessageResponse represents response/events from "message/stream"
type SendStreamingMessageResponseResult ¶
type SendStreamingMessageResponseResult interface { Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent }
type SendTaskRequest ¶
type SendTaskRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "tasks/send" - INCORRECT per A2A spec Params TaskSendParams `json:"params"` }
SendTaskRequest is a JSON-RPC request to send a message/start a task. DEPRECATED: Use SendMessageRequest with "message/send" method instead
type SendTaskResponse ¶
type SendTaskResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result *Task `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` }
SendTaskResponse is a JSON-RPC response for a send task request.
type SendTaskStreamingRequest ¶
type SendTaskStreamingRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "tasks/sendSubscribe" Params TaskSendParams `json:"params"` }
SendTaskStreamingRequest is a JSON-RPC request to send a message and subscribe to updates.
type SendTaskStreamingResponse ¶
type SendTaskStreamingResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result any `json:"result,omitempty"` // *TaskStatusUpdateEvent or *TaskArtifactUpdateEvent Error *JSONRPCError `json:"error,omitempty"` }
SendTaskStreamingResponse is a JSON-RPC response/event during a streaming task. The Result field can be TaskStatusUpdateEvent or TaskArtifactUpdateEvent.
func (*SendTaskStreamingResponse) GetArtifactUpdate ¶
func (r *SendTaskStreamingResponse) GetArtifactUpdate() *TaskArtifactUpdateEvent
GetArtifactUpdate returns the TaskArtifactUpdateEvent if the Result contains one, or nil otherwise
func (*SendTaskStreamingResponse) GetStatusUpdate ¶
func (r *SendTaskStreamingResponse) GetStatusUpdate() *TaskStatusUpdateEvent
GetStatusUpdate returns the TaskStatusUpdateEvent if the Result contains one, or nil otherwise
type SetTaskPushNotificationRequest ¶
type SetTaskPushNotificationRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "tasks/pushNotification/set" Params TaskPushNotificationConfig `json:"params"` // Note: Schema shows params is TaskPushNotificationConfig, not TaskIdParams }
SetTaskPushNotificationRequest is a JSON-RPC request to set push notification config for a task.
type SetTaskPushNotificationResponse ¶
type SetTaskPushNotificationResponse struct { JSONRPC string `json:"jsonrpc,omitempty"` // "2.0" ID any `json:"id"` Result *TaskPushNotificationConfig `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` }
SetTaskPushNotificationResponse is a JSON-RPC response for setting push notification config.
type Task ¶
type Task struct { ID string `json:"id"` ContextID *string `json:"contextId,omitempty"` Status TaskStatus `json:"status"` History []Message `json:"history,omitempty"` Artifacts []Artifact `json:"artifacts,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` Kind string `json:"kind"` // "task" }
Task represents the state and data associated with an agent task.
type TaskArtifactUpdateEvent ¶
type TaskArtifactUpdateEvent struct { Kind string `json:"kind"` // "artifact-update" TaskID string `json:"taskId"` ContextID string `json:"contextId,omitempty"` Artifact Artifact `json:"artifact"` Append bool `json:"append,omitempty"` // Indicates if this is an append to existing artifact LastChunk bool `json:"lastChunk,omitempty"` // Indicates if this is the last chunk of the artifact Metadata map[string]any `json:"metadata,omitempty"` }
TaskArtifactUpdateEvent represents an event indicating a new or updated artifact.
func ConvertEventToTaskArtifactUpdate ¶
func ConvertEventToTaskArtifactUpdate(event *core.Event, filename string, version int) *TaskArtifactUpdateEvent
type TaskIdParams ¶
type TaskIdParams struct { ID string `json:"id"` Metadata map[string]any `json:"metadata,omitempty"` }
TaskIdParams provides parameters containing just a task ID.
type TaskNotCancelableError ¶
type TaskNotCancelableError struct { Code int `json:"code"` // Should be -32002 Message string `json:"message"` // Should be "Task cannot be canceled" Data any `json:"data"` // Should be null }
TaskNotCancelableError indicates a task cannot be canceled (e.g., already completed).
func (*TaskNotCancelableError) Error ¶
func (e *TaskNotCancelableError) Error() string
Error implements the error interface for TaskNotCancelableError
type TaskNotFoundError ¶
type TaskNotFoundError struct { Code int `json:"code"` // Should be -32001 Message string `json:"message"` // Should be "Task not found" Data any `json:"data"` // Should be null }
TaskNotFoundError indicates the requested task ID was not found.
func (*TaskNotFoundError) Error ¶
func (e *TaskNotFoundError) Error() string
Error implements the error interface for TaskNotFoundError
type TaskPushNotificationConfig ¶
type TaskPushNotificationConfig struct { TaskID string `json:"taskId"` PushNotificationConfig PushNotificationConfig `json:"pushNotificationConfig"` }
TaskPushNotificationConfig associates a task ID with its push notification settings.
type TaskQueryParams ¶
type TaskQueryParams struct { ID string `json:"id"` HistoryLength *int `json:"historyLength,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` }
TaskQueryParams provides parameters for querying a task, including history length.
type TaskResubscriptionRequest ¶
type TaskResubscriptionRequest struct { JSONRPC string `json:"jsonrpc"` // "2.0" ID any `json:"id,omitempty"` Method string `json:"method"` // "tasks/resubscribe" Params TaskQueryParams `json:"params"` }
TaskResubscriptionRequest is a JSON-RPC request to resubscribe to task updates.
type TaskSendParams ¶
type TaskSendParams struct { ID string `json:"id"` SessionID *string `json:"sessionId,omitempty"` Message Message `json:"message"` PushNotification *PushNotificationConfig `json:"pushNotification,omitempty"` HistoryLength *int `json:"historyLength,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` }
TaskSendParams provides parameters for sending a message to a task.
type TaskState ¶
type TaskState string
TaskState represents the possible states of a task.
const ( TaskStateSubmitted TaskState = "submitted" TaskStateWorking TaskState = "working" TaskStateInputRequired TaskState = "input-required" TaskStateCompleted TaskState = "completed" TaskStateCanceled TaskState = "canceled" TaskStateFailed TaskState = "failed" TaskStateRejected TaskState = "rejected" TaskStateAuthRequired TaskState = "auth-required" TaskStateUnknown TaskState = "unknown" )
type TaskStatus ¶
type TaskStatus struct { State TaskState `json:"state"` Message *Message `json:"message,omitempty"` Timestamp *time.Time `json:"timestamp,omitempty"` // Use pointer to allow omission if not present }
TaskStatus represents the current status of a task.
type TaskStatusUpdateEvent ¶
type TaskStatusUpdateEvent struct { Kind string `json:"kind"` // "status-update" TaskId string `json:"taskId"` ContextId string `json:"contextId,omitempty"` Status TaskStatus `json:"status"` Final bool `json:"final,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` }
TaskStatusUpdateEvent represents an event indicating a change in task status.
func ConvertEventToTaskStatusUpdate ¶
func ConvertEventToTaskStatusUpdate(event *core.Event, invocationCtx *core.InvocationContext) *TaskStatusUpdateEvent
ConvertEventToTaskStatusUpdate converts an ADK event to a task status update message
type TextPart ¶
type TextPart struct { Type string `json:"type"` // "text" Text string `json:"text"` Metadata map[string]any `json:"metadata,omitempty"` }
TextPart represents a plain text part of a message or artifact.
type UnsupportedOperationError ¶
type UnsupportedOperationError struct { Code int `json:"code"` // Should be -32004 Message string `json:"message"` // Should be "This operation is not supported" Data any `json:"data"` // Should be null }
UnsupportedOperationError indicates the requested operation is not supported by the agent.
func (*UnsupportedOperationError) Error ¶
func (e *UnsupportedOperationError) Error() string
Error implements the error interface for UnsupportedOperationError