a2a

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 8 Imported by: 89

Documentation

Overview

Package a2a contains core types and constants from the A2A protocol shared by client and server implementations. These types implement the A2A specification and are transport-agnostic.

Additionally, the package provides factory methods for types implementing the Event interface.

Index

Constants

View Source
const SvcParamExtensions = "A2A-Extensions"

SvcParamExtensions is the key for the service parameter that specifies the A2A extensions that the client wants to use for the request.

View Source
const SvcParamVersion = "A2A-Version"

SvcParamVersion is the key for the service parameter that specifies the A2A protocol version that the client is using.

Variables

View Source
var (
	// ErrParseError indicates that server received payload that was not well-formed.
	ErrParseError = errors.New("parse error")

	// ErrInvalidRequest indicates that server received a well-formed payload which was not a valid request.
	ErrInvalidRequest = errors.New("invalid request")

	// ErrMethodNotFound indicates that a method does not exist or is not supported.
	ErrMethodNotFound = errors.New("method not found")

	// ErrInvalidParams indicates that params provided for the method were invalid (e.g., wrong type, missing required field).
	ErrInvalidParams = errors.New("invalid params")

	// ErrInternalError indicates an unexpected error occurred on the server during processing.
	ErrInternalError = errors.New("internal error")

	// ErrServerError reserved for implementation-defined server-errors.
	ErrServerError = errors.New("server error")

	// ErrTaskNotFound indicates that a task with the provided ID was not found.
	ErrTaskNotFound = errors.New("task not found")

	// ErrTaskNotCancelable indicates that the task was in a state where it could not be canceled.
	ErrTaskNotCancelable = errors.New("task cannot be canceled")

	// ErrPushNotificationNotSupported indicates that the agent does not support push notifications.
	ErrPushNotificationNotSupported = errors.New("push notification not supported")

	// ErrUnsupportedOperation indicates that the requested operation is not supported by the agent.
	ErrUnsupportedOperation = errors.New("this operation is not supported")

	// ErrUnsupportedContentType indicates an incompatibility between the requested
	// content types and the agent's capabilities.
	ErrUnsupportedContentType = errors.New("incompatible content types")

	// ErrInvalidAgentResponse indicates that the agent returned a response that
	// does not conform to the specification for the current method.
	ErrInvalidAgentResponse = errors.New("invalid agent response")

	// ErrExtendedCardNotConfigured indicates that the agent does not have an Authenticated
	// Extended Card configured.
	ErrExtendedCardNotConfigured = errors.New("extended card not configured")

	// ErrExtensionSupportRequired indicates that the Client requested use of an extension marked as
	// required: true in the Agent Card but the client did not declare support for it in the request.
	ErrExtensionSupportRequired = errors.New("extension support required")

	// ErrVersionNotSupported indicates that the The A2A protocol version specified in the request
	// (via A2A-Version service parameter) is not supported by the agent.
	ErrVersionNotSupported = errors.New("this version is not supported")

	// ErrUnauthenticated indicates that the request does not have valid authentication credentials.
	ErrUnauthenticated = errors.New("unauthenticated")

	// ErrUnauthorized indicates that the caller does not have permission to execute the specified operation.
	ErrUnauthorized = errors.New("permission denied")
)

https://a2a-protocol.org/latest/specification/#8-error-handling

Functions

func NewContextID

func NewContextID() string

NewContextID generates a new random context identifier.

func NewMessageID

func NewMessageID() string

NewMessageID generates a new random message identifier.

Types

type APIKeySecurityScheme

type APIKeySecurityScheme struct {
	// An optional description for the security scheme.
	Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`

	// The location of the API key. Valid values are "query", "header", or "cookie".
	Location APIKeySecuritySchemeLocation `json:"location" yaml:"location" mapstructure:"location"`

	// The name of the header, query, or cookie parameter to be used.
	Name string `json:"name" yaml:"name" mapstructure:"name"`
}

APIKeySecurityScheme defines a security scheme using an API key.

type APIKeySecuritySchemeLocation

type APIKeySecuritySchemeLocation string

APIKeySecuritySchemeLocation defines a set of permitted values for the expected API key location in APIKeySecurityScheme.

const (
	// APIKeySecuritySchemeLocationCookie indicates the API key is passed in a cookie.
	APIKeySecuritySchemeLocationCookie APIKeySecuritySchemeLocation = "cookie"
	// APIKeySecuritySchemeLocationHeader indicates the API key is passed in a header.
	APIKeySecuritySchemeLocationHeader APIKeySecuritySchemeLocation = "header"
	// APIKeySecuritySchemeLocationQuery indicates the API key is passed in a query parameter.
	APIKeySecuritySchemeLocationQuery APIKeySecuritySchemeLocation = "query"
)

type AgentCapabilities

type AgentCapabilities struct {
	// Extensions is a list of protocol extensions supported by the agent.
	Extensions []AgentExtension `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"`

	// PushNotifications indicates if the agent supports sending push notifications for asynchronous task updates.
	PushNotifications bool `json:"pushNotifications,omitempty" yaml:"pushNotifications,omitempty" mapstructure:"pushNotifications,omitempty"`

	// Streaming indicates if the agent supports streaming responses.
	Streaming bool `json:"streaming,omitempty" yaml:"streaming,omitempty" mapstructure:"streaming,omitempty"`

	// ExtendedAgentCard indicates if the agent supports providing an extended agent card when authenticated.
	ExtendedAgentCard bool `json:"extendedAgentCard,omitempty" yaml:"extendedAgentCard,omitempty" mapstructure:"extendedAgentCard,omitempty"`
}

AgentCapabilities define optional capabilities supported by an agent.

type AgentCard

type AgentCard struct {
	// SupportedInterfaces is a list of supported transport, protocol and URL combinations.
	// This allows agents to expose multiple transports, potentially at different URLs.
	//
	// Best practices:
	// - MUST include all supported transports.
	// - MUST accurately declare the transport available at each URL
	// - MAY reuse URLs if multiple transports are available at the same endpoint
	//
	// Clients can select any interface from this list based on their transport capabilities
	// and preferences. This enables transport negotiation and fallback scenarios.
	SupportedInterfaces []*AgentInterface `json:"supportedInterfaces" yaml:"supportedInterfaces" mapstructure:"supportedInterfaces"`

	// Capabilities is a declaration of optional capabilities supported by the agent.
	Capabilities AgentCapabilities `json:"capabilities" yaml:"capabilities" mapstructure:"capabilities"`

	// DefaultInputModes a default set of supported input MIME types for all skills, which can be
	// overridden on a per-skill basis.
	DefaultInputModes []string `json:"defaultInputModes" yaml:"defaultInputModes" mapstructure:"defaultInputModes"`

	// DefaultOutputModes is a default set of supported output MIME types for all skills, which can be
	// overridden on a per-skill basis.
	DefaultOutputModes []string `json:"defaultOutputModes" yaml:"defaultOutputModes" mapstructure:"defaultOutputModes"`

	// Description is a human-readable description of the agent, assisting users and other agents
	// in understanding its purpose.
	Description string `json:"description" yaml:"description" mapstructure:"description"`

	// DocumentationURL is an optional URL to the agent's documentation.
	DocumentationURL string `json:"documentationUrl,omitempty" yaml:"documentationUrl,omitempty" mapstructure:"documentationUrl,omitempty"`

	// IconURL is an optional URL to an icon for the agent.
	IconURL string `json:"iconUrl,omitempty" yaml:"iconUrl,omitempty" mapstructure:"iconUrl,omitempty"`

	// Name is a human-readable name for the agent.
	Name string `json:"name" yaml:"name" mapstructure:"name"`

	// Provider contains information about the agent's service provider.
	Provider *AgentProvider `json:"provider,omitempty" yaml:"provider,omitempty" mapstructure:"provider,omitempty"`

	// SecurityRequirements is a list of security requirement objects that apply to all agent interactions.
	SecurityRequirements SecurityRequirementsOptions `json:"securityRequirements,omitempty" yaml:"securityRequirements,omitempty" mapstructure:"securityRequirements,omitempty"`

	// SecuritySchemes is a declaration of the security schemes available to authorize requests. The key
	// is the scheme name. Follows the OpenAPI 3.0 Security Scheme Object.
	SecuritySchemes NamedSecuritySchemes `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty" mapstructure:"securitySchemes,omitempty"`

	// Signatures is a list of JSON Web Signatures computed for this AgentCard.
	Signatures []AgentCardSignature `json:"signatures,omitempty" yaml:"signatures,omitempty" mapstructure:"signatures,omitempty"`

	// Skills is the set of skills, or distinct capabilities, that the agent can perform.
	Skills []AgentSkill `json:"skills" yaml:"skills" mapstructure:"skills"`

	// Version is the agent's own version number. The format is defined by the provider.
	Version string `json:"version" yaml:"version" mapstructure:"version"`
}

AgentCard is a self-describing manifest for an agent. It provides essential metadata including the agent's identity, capabilities, skills, supported communication methods, and security requirements.

type AgentCardSignature

type AgentCardSignature struct {
	// Header is the unprotected JWS header values.
	Header map[string]any `json:"header,omitempty" yaml:"header,omitempty" mapstructure:"header,omitempty"`

	// Protected is a JWS header for the signature. This is a Base64url-encoded JSON object, as per RFC 7515.
	Protected string `json:"protected" yaml:"protected" mapstructure:"protected"`

	// Signature is the computed signature, Base64url-encoded.
	Signature string `json:"signature" yaml:"signature" mapstructure:"signature"`
}

AgentCardSignature represents a JWS signature of an AgentCard. This follows the JSON format of an RFC 7515 JSON Web Signature (JWS).

type AgentExtension

type AgentExtension struct {
	// Description is an optional human-readable description of how this agent uses the extension.
	Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`

	// Params are optional, extension-specific configuration parameters.
	Params map[string]any `json:"params,omitempty" yaml:"params,omitempty" mapstructure:"params,omitempty"`

	// Required indicates if the client must understand and comply with the extension's
	// requirements to interact with the agent.
	Required bool `json:"required,omitempty" yaml:"required,omitempty" mapstructure:"required,omitempty"`

	// URI is the unique URI identifying the extension.
	URI string `json:"uri,omitempty" yaml:"uri,omitempty" mapstructure:"uri,omitempty"`
}

AgentExtension is a declaration of a protocol extension supported by an Agent.

type AgentInterface

type AgentInterface struct {
	// URL is the URL where this interface is available.
	URL string `json:"url" yaml:"url" mapstructure:"url"`

	// ProtocolBinding is the protocol binding supported at this URL.
	// This is an open form string, to be easily extended for other protocol bindings.
	ProtocolBinding TransportProtocol `json:"protocolBinding" yaml:"protocolBinding" mapstructure:"protocolBinding"`

	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// ProtocolVersion is the version of the A2A protocol this interface exposes.
	ProtocolVersion ProtocolVersion `json:"protocolVersion" yaml:"protocolVersion" mapstructure:"protocolVersion"`
}

AgentInterface declares a combination of a target URL and a transport protocol for interacting with the agent. This allows agents to expose the same functionality over multiple transport mechanisms.

func NewAgentInterface

func NewAgentInterface(url string, protocolBinding TransportProtocol) *AgentInterface

NewAgentInterface creates a new AgentInterface with the provided URL and protocol binding.

type AgentProvider

type AgentProvider struct {
	// Org is the name of the agent provider's organization.
	Org string `json:"organization" yaml:"organization" mapstructure:"organization"`

	// URL is a URL for the agent provider's website or relevant documentation.
	URL string `json:"url" yaml:"url" mapstructure:"url"`
}

AgentProvider represents the service provider of an agent.

type AgentSkill

type AgentSkill struct {
	// Description is a detailed description of the skill, intended to help clients or users
	// understand its purpose and functionality.
	Description string `json:"description" yaml:"description" mapstructure:"description"`

	// Examples are prompts or scenarios that this skill can handle. Provides a hint to
	// the client on how to use the skill.
	Examples []string `json:"examples,omitempty" yaml:"examples,omitempty" mapstructure:"examples,omitempty"`

	// ID is a unique identifier for the agent's skill.
	ID string `json:"id" yaml:"id" mapstructure:"id"`

	// InputModes is the set of supported input MIME types for this skill, overriding the agent's defaults.
	InputModes []string `json:"inputModes,omitempty" yaml:"inputModes,omitempty" mapstructure:"inputModes,omitempty"`

	// Name is a human-readable name for the skill.
	Name string `json:"name" yaml:"name" mapstructure:"name"`

	// OutputModes is the set of supported output MIME types for this skill, overriding the agent's defaults.
	OutputModes []string `json:"outputModes,omitempty" yaml:"outputModes,omitempty" mapstructure:"outputModes,omitempty"`

	// SecurityRequirements is a map of schemes necessary for the agent to leverage this skill.
	// As in the overall AgentCard.security, this list represents a logical OR of
	// security requirement objects.
	// Each object is a set of security schemes that must be used together (a logical AND).
	SecurityRequirements SecurityRequirementsOptions `json:"securityRequirements,omitempty" yaml:"securityRequirements,omitempty" mapstructure:"securityRequirements,omitempty"`

	// Tags is a set of keywords describing the skill's capabilities.
	Tags []string `json:"tags" yaml:"tags" mapstructure:"tags"`
}

AgentSkill represents a distinct capability or function that an agent can perform.

type Artifact

type Artifact struct {
	// ID is a unique identifier for the artifact within the scope of the task.
	ID ArtifactID `json:"artifactId" yaml:"artifactId" mapstructure:"artifactId"`

	// Description is an optional, human-readable description of the artifact.
	Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`

	// Extensions are the URIs of extensions that are relevant to this artifact.
	Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"`

	// Metadata is an optional metadata for extensions. The key is an extension-specific identifier.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`

	// Name is an optional, human-readable name for the artifact.
	Name string `json:"name,omitempty" yaml:"name,omitempty" mapstructure:"name,omitempty"`

	// Parts is an array of content parts that make up the artifact.
	Parts ContentParts `json:"parts" yaml:"parts" mapstructure:"parts"`
}

Artifact represents a file, data structure, or other resource generated by an agent during a task.

func (*Artifact) Meta added in v0.3.6

func (a *Artifact) Meta() map[string]any

Meta implements MetadataCarrier.

func (*Artifact) SetMeta added in v0.3.6

func (a *Artifact) SetMeta(k string, v any)

SetMeta implements MetadataCarrier.

type ArtifactID

type ArtifactID string

ArtifactID is a unique identifier for the artifact within the scope of the task.

func NewArtifactID

func NewArtifactID() ArtifactID

NewArtifactID generates a new random artifact identifier.

type AuthorizationCodeOAuthFlow

type AuthorizationCodeOAuthFlow struct {
	// AuthorizationURL is the authorization URL to be used for this flow.
	// This MUST be a URL and use TLS.
	AuthorizationURL string `json:"authorizationUrl" yaml:"authorizationUrl" mapstructure:"authorizationUrl"`

	// RefreshURL is an optional URL to be used for obtaining refresh tokens.
	// This MUST be a URL and use TLS.
	RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"`

	// Scopes are the available scopes for the OAuth2 security scheme. A map between the scope
	// name and a short description for it.
	Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"`

	// TokenURL is the URL to be used for this flow. This MUST be a URL and use TLS.
	TokenURL string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"`

	// PKCERequired is an optional boolean indicating whether PKCE is required for this flow.
	// PKCE should always be used for public clients and is recommended for all clients.
	PKCERequired bool `json:"pkceRequired,omitempty" yaml:"pkceRequired,omitempty" mapstructure:"pkceRequired,omitempty"`
}

AuthorizationCodeOAuthFlow defines configuration details for the OAuth 2.0 Authorization Code flow.

type CancelTaskRequest

type CancelTaskRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// ID is the ID of the task to cancel.
	ID TaskID `json:"id" yaml:"id" mapstructure:"id"`

	// Metadata is an optional metadata for extensions. The key is an extension-specific identifier.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`
}

CancelTaskRequest represents a request to cancel a task.

func (*CancelTaskRequest) Meta

func (r *CancelTaskRequest) Meta() map[string]any

Meta implements MetadataCarrier.

func (*CancelTaskRequest) SetMeta

func (r *CancelTaskRequest) SetMeta(k string, v any)

SetMeta implements MetadataCarrier.

type ClientCredentialsOAuthFlow

type ClientCredentialsOAuthFlow struct {
	// RefreshURL is an optional URL to be used for obtaining refresh tokens. This MUST be a URL.
	RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"`

	// Scopes are the available scopes for the OAuth2 security scheme. A map between the scope
	// name and a short description for it.
	Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"`

	// TokenURL is the token URL to be used for this flow. This MUST be a URL.
	TokenURL string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"`
}

ClientCredentialsOAuthFlow defines configuration details for the OAuth 2.0 Client Credentials flow.

type ContentParts

type ContentParts []*Part

ContentParts is an array of content parts that form the message body or an artifact.

func (ContentParts) MarshalJSON added in v0.3.4

func (j ContentParts) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*ContentParts) UnmarshalJSON

func (j *ContentParts) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type CreateTaskPushConfigRequest

type CreateTaskPushConfigRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// Config is the push notification configuration for this task.
	Config PushConfig `json:"config" yaml:"config" mapstructure:"config"`

	// TaskID is the ID of the task.
	TaskID TaskID `json:"taskId" yaml:"taskId" mapstructure:"taskId"`
}

CreateTaskPushConfigRequest defines request for creating a push notification configuration for a task.

type Data

type Data struct {
	Value any
}

Data represents content of a Part carrying structured data.

type DeleteTaskPushConfigRequest

type DeleteTaskPushConfigRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// TaskID is the unique identifier of the parent task.
	TaskID TaskID `json:"taskId" yaml:"taskId" mapstructure:"taskId"`

	// ID is the ID of the push notification configuration to delete.
	ID string `json:"id" yaml:"id" mapstructure:"id"`
}

DeleteTaskPushConfigRequest defines parameters for deleting a specific push notification configuration for a task.

type DeviceCodeOAuthFlow

type DeviceCodeOAuthFlow struct {
	// DeviceAuthorizationURL is the device authorization URL to be used for this flow. This MUST be a URL.
	DeviceAuthorizationURL string `json:"deviceAuthorizationUrl" yaml:"deviceAuthorizationUrl" mapstructure:"deviceAuthorizationUrl"`

	// RefreshURL is an optional URL to be used for obtaining refresh tokens. This MUST be a URL.
	RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"`

	// Scopes are the available scopes for the OAuth2 security scheme. A map between the scope
	// name and a short description for it.
	Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"`

	// TokenURL is the token URL to be used for this flow. This MUST be a URL.
	TokenURL string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"`
}

DeviceCodeOAuthFlow defines configuration details for the OAuth 2.0 Device Code flow.

type Error added in v0.3.6

type Error struct {
	// Err is the underlying error. It will be used for transport-specific code selection.
	Err error
	// Message is a human-readable description of the error returned to clients.
	Message string
	// Details can contain additional structured information about the error.
	Details map[string]any
}

Error provides control over the message and details returned to clients.

func NewError added in v0.3.6

func NewError(err error, message string) *Error

NewError creates a new A2A Error wrapping the provided error with a custom message.

func (*Error) Error added in v0.3.6

func (e *Error) Error() string

Error returns the error message.

func (*Error) Unwrap added in v0.3.6

func (e *Error) Unwrap() error

Unwrap provides access to the error cause.

func (*Error) WithDetails added in v0.3.6

func (e *Error) WithDetails(details map[string]any) *Error

WithDetails attaches structured data to the error.

type Event

type Event interface {
	TaskInfoProvider
	MetadataCarrier
	// contains filtered or unexported methods
}

Event interface is used to represent types that can be sent over a streaming connection.

type GetExtendedAgentCardRequest

type GetExtendedAgentCardRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`
}

GetExtendedAgentCardRequest defines the parameters for a request to get an extended agent card.

type GetTaskPushConfigRequest

type GetTaskPushConfigRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// TaskID is the unique identifier of the parent task.
	TaskID TaskID `json:"taskId" yaml:"taskId" mapstructure:"taskId"`

	// ID is the ID of the push notification configuration to retrieve.
	ID string `json:"id" yaml:"id" mapstructure:"id"`
}

GetTaskPushConfigRequest defines request for fetching a specific push notification configuration for a task.

type GetTaskRequest

type GetTaskRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// ID is the ID of the task to get.
	ID TaskID `json:"id" yaml:"id" mapstructure:"id"`

	// HistoryLength is the number of most recent messages from the task's history to retrieve.
	HistoryLength *int `json:"historyLength,omitempty" yaml:"historyLength,omitempty" mapstructure:"historyLength,omitempty"`
}

GetTaskRequest defines the parameters for a request to get a task.

type HTTPAuthSecurityScheme

type HTTPAuthSecurityScheme struct {
	// BearerFormat is an optional hint to the client to identify how the bearer token is formatted (e.g.,
	// "JWT"). This is primarily for documentation purposes.
	BearerFormat string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty" mapstructure:"bearerFormat,omitempty"`

	// Description is an optional description for the security scheme.
	Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`

	// Scheme is the name of the HTTP Authentication scheme to be used in the Authorization
	// header, as defined in RFC7235 (e.g., "Bearer").
	// This value should be registered in the IANA Authentication Scheme registry.
	Scheme string `json:"scheme" yaml:"scheme" mapstructure:"scheme"`
}

HTTPAuthSecurityScheme defines a security scheme using HTTP authentication.

type ImplicitOAuthFlow

type ImplicitOAuthFlow struct {
	// AuthorizationURL is the authorization URL to be used for this flow. This MUST be a URL.
	AuthorizationURL string `json:"authorizationUrl" yaml:"authorizationUrl" mapstructure:"authorizationUrl"`

	// RefreshURL is an optional URL to be used for obtaining refresh tokens. This MUST be a URL.
	RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"`

	// Scopes are the available scopes for the OAuth2 security scheme. A map between the scope
	// name and a short description for it.
	Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"`
}

ImplicitOAuthFlow defines configuration details for the OAuth 2.0 Implicit flow.

type ListTaskPushConfigRequest

type ListTaskPushConfigRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// TaskID is the unique identifier of the task.
	TaskID TaskID `json:"taskId" yaml:"taskId" mapstructure:"taskId"`

	// PageSize is the maximum number of push notification configurations to return.
	PageSize int `json:"pageSize,omitempty" yaml:"pageSize,omitempty" mapstructure:"pageSize,omitempty"`

	// PageToken is the token received from the previous ListTaskPushConfigRequest call.
	PageToken string `json:"pageToken,omitempty" yaml:"pageToken,omitempty" mapstructure:"pageToken,omitempty"`
}

ListTaskPushConfigRequest defines the request for listing all push notification configurations associated with a task.

type ListTaskPushConfigResponse

type ListTaskPushConfigResponse struct {
	// Configs is a list of push notification configurations for the task.
	Configs []*TaskPushConfig `json:"configs" yaml:"configs" mapstructure:"configs"`

	// NextPageToken is the token to use to retrieve the next page of push notification configurations.
	NextPageToken string `json:"nextPageToken,omitempty" yaml:"nextPageToken,omitempty" mapstructure:"nextPageToken,omitempty"`
}

ListTaskPushConfigResponse defines the response for a request to list push notification configurations.

type ListTasksRequest added in v0.3.4

type ListTasksRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// ContextID is the ID of the context to list tasks for.
	ContextID string `json:"contextId,omitempty" yaml:"contextId,omitempty" mapstructure:"contextId,omitempty"`

	// Status is the current state of the tasks to list.
	Status TaskState `json:"status,omitempty" yaml:"status,omitempty" mapstructure:"status,omitempty"`

	// PageSize is the maximum number of tasks to return in the response.
	// Must be between 1 and 100. If not set, the default value is 50.
	PageSize int `json:"pageSize,omitempty" yaml:"pageSize,omitempty" mapstructure:"pageSize,omitempty"`

	// PageToken is the token for retrieving the next page of results.
	PageToken string `json:"pageToken,omitempty" yaml:"pageToken,omitempty" mapstructure:"pageToken,omitempty"`

	// HistoryLength is the number of most recent messages from the task's history to retrieve in the response.
	HistoryLength int `json:"historyLength,omitempty" yaml:"historyLength,omitempty" mapstructure:"historyLength,omitempty"`

	// StatusTimestampAfter is the time to list tasks updated after.
	StatusTimestampAfter *time.Time `json:"statusTimestampAfter,omitempty" yaml:"statusTimestampAfter,omitempty" mapstructure:"statusTimestampAfter,omitempty"`

	// IncludeArtifacts is whether to include artifacts in the response.
	IncludeArtifacts bool `json:"includeArtifacts,omitempty" yaml:"includeArtifacts,omitempty" mapstructure:"includeArtifacts,omitempty"`
}

ListTasksRequest defines the parameters for a request to list tasks.

type ListTasksResponse added in v0.3.4

type ListTasksResponse struct {
	// Tasks is the list of tasks matching the specified criteria.
	Tasks []*Task `json:"tasks" yaml:"tasks" mapstructure:"tasks"`

	// TotalSize is the total number of tasks available (before pagination).
	TotalSize int `json:"totalSize" yaml:"totalSize" mapstructure:"totalSize"`

	// PageSize is the maximum number of tasks returned in the response.
	PageSize int `json:"pageSize" yaml:"pageSize" mapstructure:"pageSize"`

	// NextPageToken is the token for retrieving the next page of results.
	// Empty string if no more results.
	NextPageToken string `json:"nextPageToken" yaml:"nextPageToken" mapstructure:"nextPageToken"`
}

ListTasksResponse defines the response for a request to tasks/list.

type Message

type Message struct {
	// ID is a unique identifier for the message, typically a UUID, generated by the sender.
	ID string `json:"messageId" yaml:"messageId" mapstructure:"messageId"`

	// ContextID is the context identifier for this message, used to group related interactions.
	// An empty string means the message doesn't reference any context.
	ContextID string `json:"contextId,omitempty" yaml:"contextId,omitempty" mapstructure:"contextId,omitempty"`

	// Extensions are the URIs of extensions that are relevant to this message.
	Extensions []string `json:"extensions,omitempty" yaml:"extensions,omitempty" mapstructure:"extensions,omitempty"`

	// Metadata is an optional metadata for extensions. The key is an extension-specific identifier.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`

	// Parts is an array of content parts that form the message body. A message can be
	// composed of multiple parts of different types (e.g., text and files).
	Parts ContentParts `json:"parts" yaml:"parts" mapstructure:"parts"`

	// ReferenceTasks is a list of other task IDs that this message references for additional context.
	ReferenceTasks []TaskID `json:"referenceTaskIds,omitempty" yaml:"referenceTaskIds,omitempty" mapstructure:"referenceTaskIds,omitempty"`

	// Role identifies the sender of the message.
	Role MessageRole `json:"role" yaml:"role" mapstructure:"role"`

	// TaskID is the identifier of the task this message is part of. Can be omitted for the
	// first message of a new task.
	// An empty string means the message doesn't reference any Task.
	TaskID TaskID `json:"taskId,omitempty" yaml:"taskId,omitempty" mapstructure:"taskId,omitempty"`
}

Message represents a single message in the conversation between a user and an agent.

func NewMessage

func NewMessage(role MessageRole, parts ...*Part) *Message

NewMessage creates a new message with a random identifier.

func NewMessageForTask

func NewMessageForTask(role MessageRole, infoProvider TaskInfoProvider, parts ...*Part) *Message

NewMessageForTask creates a new message with a random identifier that references the provided Task.

func (*Message) Meta

func (m *Message) Meta() map[string]any

Meta implements MetadataCarrier.

func (*Message) SetMeta added in v0.3.6

func (m *Message) SetMeta(k string, v any)

SetMeta implements MetadataCarrier.

func (*Message) TaskInfo

func (m *Message) TaskInfo() TaskInfo

TaskInfo implements TaskInfoProvider.

type MessageRole

type MessageRole string

MessageRole represents a set of possible values that identify the message sender.

const (
	// MessageRoleUnspecified is an unspecified message role.
	MessageRoleUnspecified MessageRole = ""
	// MessageRoleAgent is an agent message role.
	MessageRoleAgent MessageRole = "agent"
	// MessageRoleUser is a user message role.
	MessageRoleUser MessageRole = "user"
)

MessageRole constants.

type MetadataCarrier added in v0.3.6

type MetadataCarrier interface {
	// Meta returns the metadata container.
	Meta() map[string]any
	// SetMeta sets the metadata value for the provided key.
	SetMeta(k string, v any)
}

MetadataCarrier provides access to extensions metadata container.

type MutualTLSSecurityScheme

type MutualTLSSecurityScheme struct {
	// Description is an optional description for the security scheme.
	Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
}

MutualTLSSecurityScheme defines a security scheme using mTLS authentication.

type NamedSecuritySchemes

type NamedSecuritySchemes map[SecuritySchemeName]SecurityScheme

NamedSecuritySchemes is a declaration of the security schemes available to authorize requests. The key is the scheme name. Follows the OpenAPI 3.0 Security Scheme Object.

func (NamedSecuritySchemes) MarshalJSON

func (s NamedSecuritySchemes) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*NamedSecuritySchemes) UnmarshalJSON

func (s *NamedSecuritySchemes) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type OAuth2SecurityScheme

type OAuth2SecurityScheme struct {
	// Description is an optional description for the security scheme.
	Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`

	// Flows is an object containing configuration information for the supported OAuth 2.0 flows.
	Flows OAuthFlows `json:"flows" yaml:"flows" mapstructure:"flows"`

	// Oauth2MetadataURL is an optional URL to the oauth2 authorization server metadata
	// [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414). TLS is required.
	Oauth2MetadataURL string `json:"oauth2MetadataUrl,omitempty" yaml:"oauth2MetadataUrl,omitempty" mapstructure:"oauth2MetadataUrl,omitempty"`
}

OAuth2SecurityScheme defines a security scheme using OAuth 2.0.

func (OAuth2SecurityScheme) MarshalJSON

func (s OAuth2SecurityScheme) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*OAuth2SecurityScheme) UnmarshalJSON

func (s *OAuth2SecurityScheme) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type OAuthFlowName

type OAuthFlowName string

OAuthFlowName defines the set of possible OAuth 2.0 flow names.

const (
	// AuthorizationCodeOAuthFlowName is the name for the Authorization Code flow.
	AuthorizationCodeOAuthFlowName OAuthFlowName = "authorizationCode"
	// ClientCredentialsOAuthFlowName is the name for the Client Credentials flow.
	ClientCredentialsOAuthFlowName OAuthFlowName = "clientCredentials"
	// ImplicitOAuthFlowName is the name for the Implicit flow.
	ImplicitOAuthFlowName OAuthFlowName = "implicit"
	// PasswordOAuthFlowName is the name for the Resource Owner Password flow.
	PasswordOAuthFlowName OAuthFlowName = "password"
	// DeviceCodeOAuthFlowName is the name for the Device Code flow.
	DeviceCodeOAuthFlowName OAuthFlowName = "deviceCode"
)

type OAuthFlows

type OAuthFlows interface {
	// contains filtered or unexported methods
}

OAuthFlows defines the configuration for the supported OAuth 2.0 flows.

type OpenIDConnectSecurityScheme

type OpenIDConnectSecurityScheme struct {
	// Description is an optional description for the security scheme.
	Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`

	// OpenIDConnectURL is the OpenID Connect Discovery URL for the OIDC provider's metadata.
	OpenIDConnectURL string `json:"openIdConnectUrl" yaml:"openIdConnectUrl" mapstructure:"openIdConnectUrl"`
}

OpenIDConnectSecurityScheme defines a security scheme using OpenID Connect.

type Part

type Part struct {
	// Types that are valid to be assigned to Content are [Text], [Raw], [Data], [URL].
	Content PartContent `json:"content" yaml:"content" mapstructure:"content"`

	// Filename is an optional name for the file (e.g., "document.pdf").
	Filename string `json:"filename,omitempty" yaml:"filename,omitempty" mapstructure:"filename,omitempty"`

	// MediaType is the media type of the part content (e.g. "text/plain", "image/png", "application/json").
	// This field is available for all part types.
	MediaType string `json:"mediaType,omitempty" yaml:"mediaType,omitempty" mapstructure:"mediaType,omitempty"`

	// Metadata is the optional metadata associated with this part.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`
}

Part is a discriminated union representing a part of a message or artifact, which can be text, a file, or structured data.

func NewDataPart

func NewDataPart(data any) *Part

NewDataPart creates a Part that contains structured data.

func NewFileURLPart

func NewFileURLPart(url URL, mimeType string) *Part

NewFileURLPart creates a Part that contains a URL.

func NewRawPart

func NewRawPart(raw []byte) *Part

NewRawPart creates a Part that contains raw bytes.

func NewTextPart

func NewTextPart(text string) *Part

NewTextPart creates a Part that contains text.

func (*Part) Data

func (p *Part) Data() any

Data is a helper that returns the data content of the part if it is a Data part.

func (Part) MarshalJSON

func (p Part) MarshalJSON() ([]byte, error)

MarshalJSON custom serializer that flattens Content into the Part object.

func (Part) Meta

func (p Part) Meta() map[string]any

Meta implements MetadataCarrier.

func (*Part) Raw

func (p *Part) Raw() []byte

Raw is a helper that returns the raw content of the part if it is a Raw part.

func (*Part) SetMeta

func (p *Part) SetMeta(k string, v any)

SetMeta implements MetadataCarrier.

func (*Part) Text

func (p *Part) Text() string

Text is a helper that returns the text content of the part if it is a Text part.

func (*Part) URL

func (p *Part) URL() URL

URL is a helper that returns the URL content of the part if it is a URL part.

func (*Part) UnmarshalJSON

func (p *Part) UnmarshalJSON(b []byte) error

UnmarshalJSON custom deserializer that hydrates Content from flattened fields.

type PartContent

type PartContent interface {
	// contains filtered or unexported methods
}

PartContent is a sealed discriminated type union for supported part content types. It exists to specify which types can be assigned to the [Part.Content] field.

type PasswordOAuthFlow

type PasswordOAuthFlow struct {
	// RefreshURL is an optional URL to be used for obtaining refresh tokens. This MUST be a URL.
	RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty" mapstructure:"refreshUrl,omitempty"`

	// Scopes are the available scopes for the OAuth2 security scheme.
	// A map between the scope name and a short description for it.
	Scopes map[string]string `json:"scopes" yaml:"scopes" mapstructure:"scopes"`

	// TokenURL is the token URL to be used for this flow. This MUST be a URL.
	TokenURL string `json:"tokenUrl" yaml:"tokenUrl" mapstructure:"tokenUrl"`
}

PasswordOAuthFlow defines configuration details for the OAuth 2.0 Resource Owner Password flow.

type ProtocolVersion added in v0.3.6

type ProtocolVersion string

ProtocolVersion is a string constant which represents a version of the protocol.

const Version ProtocolVersion = "1.0"

Version is the protocol version which SDK implements.

type PushAuthInfo

type PushAuthInfo struct {
	// Credentials is an optional credentials required by the push notification endpoint.
	Credentials string `json:"credentials,omitempty" yaml:"credentials,omitempty" mapstructure:"credentials,omitempty"`

	// Scheme is a supported authentication scheme (e.g., 'Basic', 'Bearer').
	Scheme string `json:"scheme" yaml:"scheme" mapstructure:"scheme"`
}

PushAuthInfo defines authentication details for a push notification endpoint.

type PushConfig

type PushConfig struct {
	// ID is an optional unique ID for the push notification configuration, set by the client
	// to support multiple notification callbacks.
	ID string `json:"id,omitempty" yaml:"id,omitempty" mapstructure:"id,omitempty"`

	// Auth is an optional authentication details for the agent to use when calling the
	// notification URL.
	Auth *PushAuthInfo `json:"authentication,omitempty" yaml:"authentication,omitempty" mapstructure:"authentication,omitempty"`

	// Token is an optional unique token for this task or session to validate incoming push notifications.
	Token string `json:"token,omitempty" yaml:"token,omitempty" mapstructure:"token,omitempty"`

	// URL is the callback URL where the agent should send push notifications.
	URL string `json:"url" yaml:"url" mapstructure:"url"`
}

PushConfig defines the configuration for setting up push notifications for task updates.

type Raw

type Raw []byte

Raw represents content of a Part carrying raw bytes.

type SecurityRequirements

type SecurityRequirements map[SecuritySchemeName]SecuritySchemeScopes

SecurityRequirements describes a set of security requirements that must be present on a request. For example, to specify that mutual TLS AND an oauth2 token for specific scopes is required, the following requirements object needs to be created:

map[SecuritySchemeName]SecuritySchemeScopes{
	SecuritySchemeName("oauth2"): SecuritySchemeScopes{"read", "write"},
	SecuritySchemeName("mTLS"): {}
}

type SecurityRequirementsOptions

type SecurityRequirementsOptions []SecurityRequirements

SecurityRequirementsOptions is a list of security requirement objects that apply to all agent interactions. Each object lists security schemes that can be used. Follows the OpenAPI 3.0 Security Requirement Object. This list can be seen as an OR of ANDs. Each object in the list describes one possible set of security requirements that must be present on a request. This allows specifying, for example, "callers must either use OAuth OR an API Key AND mTLS.":

SecurityRequirements: a2a.SecurityRequirementsOptions{
	map[a2a.SecuritySchemeName]a2a.SecuritySchemeScopes{
		a2a.SecuritySchemeName("apiKey"): {},
		a2a.SecuritySchemeName("oauth2"): {"read"},
	},
}

func (SecurityRequirementsOptions) MarshalJSON

func (rs SecurityRequirementsOptions) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*SecurityRequirementsOptions) UnmarshalJSON

func (rs *SecurityRequirementsOptions) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type SecurityScheme

type SecurityScheme interface {
	// contains filtered or unexported methods
}

SecurityScheme is a sealed discriminated type union for supported security schemes.

type SecuritySchemeName

type SecuritySchemeName string

SecuritySchemeName is a string used to describe a security scheme in AgentCard.SecuritySchemes and reference it the AgentCard.Security requirements.

type SecuritySchemeScopes

type SecuritySchemeScopes []string

SecuritySchemeScopes is a list of scopes a security credential must be covering.

type SendMessageConfig

type SendMessageConfig struct {
	// AcceptedOutputModes is a list of output MIME types the client is prepared to accept in the response.
	AcceptedOutputModes []string `json:"acceptedOutputModes,omitempty" yaml:"acceptedOutputModes,omitempty" mapstructure:"acceptedOutputModes,omitempty"`

	// Blocking indicates if the client will wait for the task to complete. The server may reject
	// this if the task is long-running. Server might choose to default to true.
	Blocking *bool `json:"blocking,omitempty" yaml:"blocking,omitempty" mapstructure:"blocking,omitempty"`

	// HistoryLength is the number of most recent messages from the task's history to retrieve in the response.
	HistoryLength *int `json:"historyLength,omitempty" yaml:"historyLength,omitempty" mapstructure:"historyLength,omitempty"`

	// PushConfig is configuration for the agent to send push notifications for updates after the initial response.
	PushConfig *PushConfig `` /* 127-byte string literal not displayed */
}

SendMessageConfig defines configuration options for a `message/send` or `message/stream` request.

type SendMessageRequest

type SendMessageRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// Config is an optional configuration for the send request.
	Config *SendMessageConfig `json:"configuration,omitempty" yaml:"configuration,omitempty" mapstructure:"configuration,omitempty"`

	// Message is the message object being sent to the agent.
	Message *Message `json:"message" yaml:"message" mapstructure:"message"`

	// Metadata is an optional metadata for extensions.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`
}

SendMessageRequest defines the request to send a message to an agent. This can be used to create a new task, continue an existing one, or restart a task.

func (*SendMessageRequest) Meta

func (p *SendMessageRequest) Meta() map[string]any

Meta implements MetadataCarrier.

func (*SendMessageRequest) SetMeta

func (p *SendMessageRequest) SetMeta(k string, v any)

SetMeta implements MetadataCarrier.

type SendMessageResult

type SendMessageResult interface {
	Event
	// contains filtered or unexported methods
}

SendMessageResult represents a response for non-streaming message send.

type StreamResponse

type StreamResponse struct {
	// Event is the event to be sent over the streaming connection.
	Event
}

StreamResponse is a wrapper around Event that can be sent over a streaming connection. with a single field matching the event type name.

func (StreamResponse) MarshalJSON

func (sr StreamResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*StreamResponse) UnmarshalJSON

func (sr *StreamResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type SubscribeToTaskRequest

type SubscribeToTaskRequest struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// ID is the ID of the task to subscribe to.
	ID TaskID `json:"id" yaml:"id" mapstructure:"id"`
}

SubscribeToTaskRequest represents a request to subscribe to task events.

type Task

type Task struct {
	// ID is a unique identifier for the task, generated by the server for a new task.
	ID TaskID `json:"id" yaml:"id" mapstructure:"id"`

	// Artifacts is a collection of artifacts generated by the agent during the execution of the task.
	Artifacts []*Artifact `json:"artifacts,omitempty" yaml:"artifacts,omitempty" mapstructure:"artifacts,omitempty"`

	// ContextID is a server-generated identifier for maintaining context across multiple related
	// tasks or interactions. Required to be non empty.
	ContextID string `json:"contextId" yaml:"contextId" mapstructure:"contextId"`

	// History is an array of messages exchanged during the task, representing the conversation history.
	History []*Message `json:"history,omitempty" yaml:"history,omitempty" mapstructure:"history,omitempty"`

	// Metadata is an optional metadata for extensions. The key is an extension-specific identifier.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`

	// Status is the current status of the task, including its state and a descriptive message.
	Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"`
}

Task represents a single, stateful operation or conversation between a client and an agent.

func NewSubmittedTask

func NewSubmittedTask(infoProvider TaskInfoProvider, initialMessage *Message) *Task

NewSubmittedTask is a utility for creating a Task in submitted state from the initial Message. New values are generated for task and context id when they are missing.

func (*Task) Meta

func (t *Task) Meta() map[string]any

Meta implements MetadataCarrier.

func (*Task) SetMeta added in v0.3.6

func (t *Task) SetMeta(k string, v any)

SetMeta implements MetadataCarrier.

func (*Task) TaskInfo

func (t *Task) TaskInfo() TaskInfo

TaskInfo implements TaskInfoProvider.

type TaskArtifactUpdateEvent

type TaskArtifactUpdateEvent struct {
	// Append indicates if the content of this artifact should be appended to a previously sent
	// artifact with the same ID.
	Append bool `json:"append,omitempty" yaml:"append,omitempty" mapstructure:"append,omitempty"`

	// Artifact is the artifact that was generated or updated.
	Artifact *Artifact `json:"artifact" yaml:"artifact" mapstructure:"artifact"`

	// ContextID is the context ID associated with the task. Required to be non-empty.
	ContextID string `json:"contextId" yaml:"contextId" mapstructure:"contextId"`

	// LastChunk indicates if this is the final chunk of the artifact.
	LastChunk bool `json:"lastChunk,omitempty" yaml:"lastChunk,omitempty" mapstructure:"lastChunk,omitempty"`

	// TaskID is the ID of the task this artifact belongs to.
	TaskID TaskID `json:"taskId" yaml:"taskId" mapstructure:"taskId"`

	// Metadata is an optional metadata for extensions.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`
}

TaskArtifactUpdateEvent is an event sent by the agent to notify the client that an artifact has been generated or updated. This is typically used in streaming models.

func NewArtifactEvent

func NewArtifactEvent(infoProvider TaskInfoProvider, parts ...*Part) *TaskArtifactUpdateEvent

NewArtifactEvent create a TaskArtifactUpdateEvent for an Artifact with a random ID.

func NewArtifactUpdateEvent

func NewArtifactUpdateEvent(infoProvider TaskInfoProvider, id ArtifactID, parts ...*Part) *TaskArtifactUpdateEvent

NewArtifactUpdateEvent creates a TaskArtifactUpdateEvent that represents an update of the artifact with the provided ID.

func (*TaskArtifactUpdateEvent) Meta

func (e *TaskArtifactUpdateEvent) Meta() map[string]any

Meta implements MetadataCarrier.

func (*TaskArtifactUpdateEvent) SetMeta added in v0.3.6

func (e *TaskArtifactUpdateEvent) SetMeta(k string, v any)

SetMeta implements MetadataCarrier.

func (*TaskArtifactUpdateEvent) TaskInfo

func (e *TaskArtifactUpdateEvent) TaskInfo() TaskInfo

TaskInfo implements TaskInfoProvider.

type TaskID

type TaskID string

TaskID is a unique identifier for the task, generated by the server for a new task.

func NewTaskID

func NewTaskID() TaskID

NewTaskID generates a new random task identifier.

type TaskInfo

type TaskInfo struct {
	// TaskID is an id of the task.
	TaskID TaskID
	// ContextID is an id of the interactions group the task belong to.
	ContextID string
}

TaskInfo represents information about the Task and the group of interactions it belongs to. Values might be empty which means the TaskInfoProvider is not associated with any tasks. An example would be the first user message.

func (TaskInfo) TaskInfo added in v0.3.5

func (ti TaskInfo) TaskInfo() TaskInfo

TaskInfo implements TaskInfoProvider so that the struct can be passed to core type constructor functions. For example: a2a.NewMessageForTask(role, a2a.TaskInfo{...}).

type TaskInfoProvider

type TaskInfoProvider interface {
	// TaskInfo returns information about the task.
	TaskInfo() TaskInfo
}

TaskInfoProvider provides information about the Task.

type TaskPushConfig

type TaskPushConfig struct {
	// Tenant is an optional ID of the agent owner.
	Tenant string `json:"tenant,omitempty" yaml:"tenant,omitempty" mapstructure:"tenant,omitempty"`

	// Config is the push notification configuration for this task.
	Config PushConfig `json:"config" yaml:"config" mapstructure:"config"`

	// TaskID is the ID of the task.
	TaskID TaskID `json:"taskId" yaml:"taskId" mapstructure:"taskId"`
}

TaskPushConfig is a container associating a push notification configuration with a specific task.

type TaskState

type TaskState string

TaskState defines a set of possible task states.

const (
	// TaskStateUnspecified represents a missing TaskState value.
	TaskStateUnspecified TaskState = ""
	// TaskStateAuthRequired means the task requires authentication to proceed.
	TaskStateAuthRequired TaskState = "AUTH_REQUIRED"
	// TaskStateCanceled means the task has been canceled by the user.
	TaskStateCanceled TaskState = "CANCELED"
	// TaskStateCompleted means the task has been successfully completed.
	TaskStateCompleted TaskState = "COMPLETED"
	// TaskStateFailed means the task failed due to an error during execution.
	TaskStateFailed TaskState = "FAILED"
	// TaskStateInputRequired means the task is paused and waiting for input from the user.
	TaskStateInputRequired TaskState = "INPUT_REQUIRED"
	// TaskStateRejected means the task was rejected by the agent and was not started.
	TaskStateRejected TaskState = "REJECTED"
	// TaskStateSubmitted means the task has been submitted and is awaiting execution.
	TaskStateSubmitted TaskState = "SUBMITTED"
	// TaskStateUnknown means the task is in an unknown or indeterminate state.
	TaskStateUnknown TaskState = "UNKNOWN"
	// TaskStateWorking means The agent is actively working on the task.
	TaskStateWorking TaskState = "WORKING"
)

func (TaskState) Terminal

func (ts TaskState) Terminal() bool

Terminal returns true for states in which a Task becomes immutable, i.e. no further changes to the Task are permitted.

type TaskStatus

type TaskStatus struct {
	// Message is an optional, human-readable message providing more details about the current status.
	Message *Message `json:"message,omitempty" yaml:"message,omitempty" mapstructure:"message,omitempty"`

	// State is the current state of the task's lifecycle.
	State TaskState `json:"state" yaml:"state" mapstructure:"state"`

	// Timestamp is a datetime indicating when this status was recorded.
	Timestamp *time.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty" mapstructure:"timestamp,omitempty"`
}

TaskStatus represents the status of a task at a specific point in time.

type TaskStatusUpdateEvent

type TaskStatusUpdateEvent struct {
	// ContextID is the context ID associated with the task. Required to be non-empty.
	ContextID string `json:"contextId" yaml:"contextId" mapstructure:"contextId"`

	// Status is the new status of the task.
	Status TaskStatus `json:"status" yaml:"status" mapstructure:"status"`

	// TaskID is the ID of the task that was updated.
	TaskID TaskID `json:"taskId" yaml:"taskId" mapstructure:"taskId"`

	// Metadata is an optional metadata for extensions.
	Metadata map[string]any `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`
}

TaskStatusUpdateEvent is an event sent by the agent to notify the client of a change in a task's status. This is typically used in streaming or subscription models.

func NewStatusUpdateEvent

func NewStatusUpdateEvent(infoProvider TaskInfoProvider, state TaskState, msg *Message) *TaskStatusUpdateEvent

NewStatusUpdateEvent creates a TaskStatusUpdateEvent that references the provided Task.

func (*TaskStatusUpdateEvent) Meta

func (e *TaskStatusUpdateEvent) Meta() map[string]any

Meta implements MetadataCarrier.

func (*TaskStatusUpdateEvent) SetMeta added in v0.3.6

func (e *TaskStatusUpdateEvent) SetMeta(k string, v any)

SetMeta implements MetadataCarrier.

func (*TaskStatusUpdateEvent) TaskInfo

func (e *TaskStatusUpdateEvent) TaskInfo() TaskInfo

TaskInfo implements TaskInfoProvider.

type Text

type Text string

Text represents content of a Part carrying text.

type TransportProtocol

type TransportProtocol string

TransportProtocol represents a transport protocol which a client and an agent can use for communication. Custom protocols are allowed and the type MUST NOT be treated as an enum.

const (
	// TransportProtocolJSONRPC defines the JSON-RPC transport protocol.
	TransportProtocolJSONRPC TransportProtocol = "JSONRPC"
	// TransportProtocolGRPC defines the gRPC transport protocol.
	TransportProtocolGRPC TransportProtocol = "GRPC"
	// TransportProtocolHTTPJSON defines the HTTP+JSON transport protocol.
	TransportProtocolHTTPJSON TransportProtocol = "HTTP+JSON"
)

type URL

type URL string

URL represents content of a Part carrying a URL.

Jump to

Keyboard shortcuts

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