Class AgentCard.Builder
- Enclosing class:
- AgentCard
AgentCard instances.
The Builder pattern is used to enforce immutability of AgentCard objects while providing a fluent API for setting required and optional fields. This approach ensures that once an AgentCard is created, its state cannot be modified, which is important for thread-safety and protocol correctness.
Example usage:
AgentCard card = AgentCard.builder()
.name("Weather Agent")
.description("Provides weather information")
.supportedInterfaces(List.of(
new AgentInterface("JSONRPC", "http://localhost:9999")))
.version("1.0.0")
.capabilities(new AgentCapabilities.Builder()
.streaming(true)
.build())
.defaultInputModes(List.of("text"))
.defaultOutputModes(List.of("text"))
.skills(List.of(
new AgentSkill.Builder()
.id("weather_query")
.name("Weather Queries")
.build()
))
.build();
-
Method Summary
Modifier and TypeMethodDescriptionadditionalInterfaces(List<Legacy_0_3_AgentInterface> additionalInterfaces) build()Builds an immutableAgentCardfrom the current builder state.capabilities(AgentCapabilities capabilities) Sets the capabilities supported by this agent.defaultInputModes(List<String> defaultInputModes) Sets the list of supported input modes.defaultOutputModes(List<String> defaultOutputModes) Sets the list of supported output modes.description(String description) Sets a brief description of the agent's purpose and functionality.documentationUrl(String documentationUrl) Sets the URL to human-readable documentation for the agent.Sets the URL to an icon representing the agent.Sets the human-readable name of the agent.preferredTransport(String preferredTransport) provider(AgentProvider provider) Sets information about the organization or entity providing the agent.securityRequirements(List<SecurityRequirement> securityRequirements) Sets the list of security requirements for accessing the agent.securitySchemes(Map<String, SecurityScheme> securitySchemes) Sets the map of security scheme definitions.signatures(List<AgentCardSignature> signatures) Sets the digital signatures verifying the authenticity of the agent card.skills(List<AgentSkill> skills) Sets the list of skills that this agent can perform.supportedInterfaces(List<AgentInterface> supportedInterfaces) Sets the ordered list of supported protocol interfaces (first entry is preferred).Sets the version of the agent implementation.
-
Method Details
-
name
Sets the human-readable name of the agent.- Parameters:
name- the agent name (required)- Returns:
- this builder for method chaining
-
description
Sets a brief description of the agent's purpose and functionality.- Parameters:
description- the agent description (required)- Returns:
- this builder for method chaining
-
provider
Sets information about the organization or entity providing the agent.- Parameters:
provider- the agent provider (optional)- Returns:
- this builder for method chaining
-
version
Sets the version of the agent implementation.- Parameters:
version- the agent version (required)- Returns:
- this builder for method chaining
-
documentationUrl
Sets the URL to human-readable documentation for the agent.- Parameters:
documentationUrl- the documentation URL (optional)- Returns:
- this builder for method chaining
-
capabilities
Sets the capabilities supported by this agent.Capabilities define optional features such as streaming responses, push notifications, and state transition history.
- Parameters:
capabilities- the agent capabilities (required)- Returns:
- this builder for method chaining
- See Also:
-
defaultInputModes
Sets the list of supported input modes.Input modes define the formats the agent can accept, such as "text", "audio", or "image".
- Parameters:
defaultInputModes- the list of input modes (required, must not be empty)- Returns:
- this builder for method chaining
-
defaultOutputModes
Sets the list of supported output modes.Output modes define the formats the agent can produce, such as "text", "audio", or "image".
- Parameters:
defaultOutputModes- the list of output modes (required, must not be empty)- Returns:
- this builder for method chaining
-
skills
Sets the list of skills that this agent can perform.Skills represent distinct capabilities or operations the agent can execute, such as "weather_query" or "language_translation".
- Parameters:
skills- the list of agent skills (required, must not be empty)- Returns:
- this builder for method chaining
- See Also:
-
securitySchemes
Sets the map of security scheme definitions.Security schemes define authentication and authorization methods supported by the agent, such as OAuth2, API keys, or HTTP authentication.
- Parameters:
securitySchemes- map of scheme names to definitions (optional)- Returns:
- this builder for method chaining
- See Also:
-
securityRequirements
Sets the list of security requirements for accessing the agent.- Parameters:
securityRequirements- the list of security requirements (optional)- Returns:
- this builder for method chaining
- See Also:
-
iconUrl
Sets the URL to an icon representing the agent.- Parameters:
iconUrl- the icon URL (optional)- Returns:
- this builder for method chaining
-
supportedInterfaces
Sets the ordered list of supported protocol interfaces (first entry is preferred).Each interface defines a combination of protocol binding (e.g., "JSONRPC", "GRPC", "REST") and URL endpoint for accessing the agent. This is the primary field for declaring how clients can communicate with the agent as of protocol version 1.0.0.
Example:
.supportedInterfaces(List.of( new AgentInterface("JSONRPC", "http://localhost:9999"), new AgentInterface("GRPC", "grpc://localhost:9090") ))- Parameters:
supportedInterfaces- the ordered list of supported interfaces (required)- Returns:
- this builder for method chaining
- See Also:
-
signatures
Sets the digital signatures verifying the authenticity of the agent card.Signatures provide cryptographic proof that the agent card was issued by a trusted authority and has not been tampered with.
- Parameters:
signatures- the list of signatures (optional)- Returns:
- this builder for method chaining
- See Also:
-
preferredTransport
-
url
-
additionalInterfaces
-
build
Builds an immutableAgentCardfrom the current builder state.This method applies default values for optional fields.
- Returns:
- a new AgentCard instance
- Throws:
IllegalArgumentException- if any required field is null
-