Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions samples/AgentServer/AgentServer.http
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Query agent card for the echo agent
GET {{host}}/echo/.well-known/agent.json

## curl -N -X GET http://localhost:5048/echo/.well-known/agent.json
### curl -N -X GET http://localhost:5048/echo/.well-known/agent.json

### Send a message to the echo agent
POST {{host}}/echo
Expand Down Expand Up @@ -49,21 +49,19 @@ Content-Type: application/json
}
}

### curl -N -X POST http://localhost:5048/echo -H "Content-Type: application/json" -d '{ "id": "3","jsonrpc": "2.0","method": "task/sendsubscribe","params": {"id": "1234","message": {"role": "user","parts": [{"type": "text","text": "Hello, world!"}]}}}'


## curl -N -X POST http://localhost:5048/echo -H "Content-Type: application/json" -d '{ "id": "3","jsonrpc": "2.0","method": "task/sendsubscribe","params": {"id": "1234","message": {"role": "user","parts": [{"type": "text","text": "Hello, world!"}]}}}'

###
### Retrieve a task
POST {{host}}/echotasks
Content-Type: application/json

{
"id": "3",
"jsonrpc": "2.0",
"method": "task/get",
"method": "tasks/get",
"params": {
"id": "40dfa726-bc05-4fd4-aa3d-763d5972c9d0"
}
}
}

### SendSubscribe the echo agent
Expand Down Expand Up @@ -132,17 +130,17 @@ Content-Type: application/json
}
}

###
### Retrieve a task
POST {{host}}/hostedclient
Content-Type: application/json

{
"id": "d589ff00-daba-49a0-a01c-fa2a0924ada3",
"jsonrpc": "2.0",
"method": "task/get",
"method": "tasks/get",
"params": {
"id": "b6d9ce5c-c457-47af-be95-6bed646ab667"
}
}
}


Expand Down Expand Up @@ -179,7 +177,7 @@ Content-Type: application/json
{
"id": "2",
"jsonrpc": "2.0",
"method": "task/get",
"method": "tasks/get",
"params": {
"id": "c65e7047-2938-432f-bae0-660d6d9fda50"
}
Expand Down
2 changes: 1 addition & 1 deletion src/A2A.AspNetCore/A2AHttpProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ internal static async Task<IResult> SetPushNotification(TaskManager taskManager,
var taskIdParams = new TaskIdParams { Id = id };
var result = await taskManager.SetPushNotificationAsync(new TaskPushNotificationConfig
{
Id = id,
TaskId = id,
PushNotificationConfig = pushNotificationConfig
});

Expand Down
8 changes: 7 additions & 1 deletion src/A2A/JsonRpc/JsonRpcError.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace A2A;

Expand All @@ -10,17 +11,22 @@ public class JsonRpcError
/// <summary>
/// Gets or sets the number that indicates the error type that occurred.
/// </summary>
public int Code { get; set; }
[JsonPropertyName("code")]
[JsonRequired]
public int Code { get; set; } = 0;

/// <summary>
/// Gets or sets the string providing a short description of the error.
/// </summary>
[JsonPropertyName("message")]
[JsonRequired]
public string Message { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the primitive or structured value that contains additional information about the error.
/// This may be omitted.
/// </summary>
[JsonPropertyName("data")]
public JsonElement? Data { get; set; }

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/A2A/JsonRpc/JsonRpcRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class JsonRpcRequest
/// MUST be exactly "2.0".
/// </remarks>
[JsonPropertyName("jsonrpc")]
[JsonRequired]

public string JsonRpc { get; set; } = "2.0";

/// <summary>
Expand All @@ -30,6 +32,7 @@ public class JsonRpcRequest
/// Gets or sets the string containing the name of the method to be invoked.
/// </summary>
[JsonPropertyName("method")]
[JsonRequired]
public string Method { get; set; } = string.Empty;

/// <summary>
Expand Down
19 changes: 10 additions & 9 deletions src/A2A/Models/AgentCard.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace A2A;
Expand All @@ -18,7 +17,7 @@ public class AgentCard
/// Gets or sets the human readable name of the agent.
/// </summary>
[JsonPropertyName("name")]
[Required]
[JsonRequired]
public string Name { get; set; } = string.Empty;

/// <summary>
Expand All @@ -30,8 +29,8 @@ public class AgentCard
/// (e.g., "This agent helps users find recipes, plan meals, and get cooking instructions.")
/// </remarks>
[JsonPropertyName("description")]
[Required]
public string? Description { get; set; }
[JsonRequired]
public string Description { get; set; } = string.Empty;

/// <summary>
/// Gets or sets a URL to the address the agent is hosted at.
Expand All @@ -40,7 +39,7 @@ public class AgentCard
/// This represents the preferred endpoint as declared by the agent.
/// </remarks>
[JsonPropertyName("url")]
[Required]
[JsonRequired]
public string Url { get; set; } = string.Empty;

/// <summary>
Expand All @@ -53,14 +52,14 @@ public class AgentCard
/// Gets or sets the version of the agent - format is up to the provider.
/// </summary>
[JsonPropertyName("version")]
[Required]
[JsonRequired]
public string Version { get; set; } = string.Empty;

/// <summary>
/// The version of the A2A protocol this agent supports.
/// </summary>
[JsonPropertyName("protocolVersion")]
[Required]
[JsonRequired]
public string ProtocolVersion { get; set; } = "0.2.3";

/// <summary>
Expand All @@ -73,7 +72,7 @@ public class AgentCard
/// Gets or sets the optional capabilities supported by the agent.
/// </summary>
[JsonPropertyName("capabilities")]
[Required]
[JsonRequired]
public AgentCapabilities Capabilities { get; set; } = new AgentCapabilities();

/// <summary>
Expand All @@ -95,19 +94,21 @@ public class AgentCard
/// This can be overridden per-skill. Supported media types for input.
/// </remarks>
[JsonPropertyName("defaultInputModes")]
[JsonRequired]
public List<string> DefaultInputModes { get; set; } = ["text"];

/// <summary>
/// Gets or sets the supported media types for output.
/// </summary>
[JsonPropertyName("defaultOutputModes")]
[JsonRequired]
public List<string> DefaultOutputModes { get; set; } = ["text"];

/// <summary>
/// Gets or sets the skills that are a unit of capability that an agent can perform.
/// </summary>
[JsonPropertyName("skills")]
[Required]
[JsonRequired]
public List<AgentSkill> Skills { get; set; } = [];

/// <summary>
Expand Down
7 changes: 3 additions & 4 deletions src/A2A/Models/AgentInterface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace A2A;

Expand All @@ -16,13 +15,13 @@ public class AgentInterface
/// The core ones officially supported are JSONRPC, GRPC, and HTTP+JSON.
/// </remarks>
[JsonPropertyName("transport")]
[Required]
[JsonRequired]
public required AgentTransport Transport { get; set; }

/// <summary>
/// The target URL for the agent interface.
/// </summary>
[JsonPropertyName("url")]
[Required]
[JsonRequired]
public required string Url { get; set; }
}
5 changes: 2 additions & 3 deletions src/A2A/Models/AgentProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace A2A;
Expand All @@ -12,13 +11,13 @@ public class AgentProvider
/// Agent provider's organization name.
/// </summary>
[JsonPropertyName("organization")]
[Required]
[JsonRequired]
public string Organization { get; set; } = string.Empty;

/// <summary>
/// Agent provider's URL.
/// </summary>
[JsonPropertyName("url")]
[Required]
[JsonRequired]
public string Url { get; set; } = string.Empty;
}
13 changes: 6 additions & 7 deletions src/A2A/Models/AgentSkill.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace A2A;
Expand All @@ -12,14 +11,14 @@ public class AgentSkill
/// Unique identifier for the agent's skill.
/// </summary>
[JsonPropertyName("id")]
[Required]
[JsonRequired]
public string Id { get; set; } = string.Empty;

/// <summary>
/// Human readable name of the skill.
/// </summary>
[JsonPropertyName("name")]
[Required]
[JsonRequired]
public string Name { get; set; } = string.Empty;

/// <summary>
Expand All @@ -29,15 +28,15 @@ public class AgentSkill
/// Will be used by the client or a human as a hint to understand what the skill does.
/// </remarks>
[JsonPropertyName("description")]
[Required]
public string? Description { get; set; }
[JsonRequired]
public string Description { get; set; } = string.Empty;

/// <summary>
/// Set of tagwords describing classes of capabilities for this specific skill.
/// </summary>
[JsonPropertyName("tags")]
[Required]
public List<string>? Tags { get; set; }
[JsonRequired]
public List<string> Tags { get; set; } = [];

/// <summary>
/// The set of example scenarios that the skill can perform.
Expand Down
2 changes: 1 addition & 1 deletion src/A2A/Models/AgentTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AgentTask : A2AResponse
/// </summary>
[JsonPropertyName("contextId")]
[JsonRequired]
public string? ContextId { get; set; }
public string ContextId { get; set; } = string.Empty;

/// <summary>
/// Current status of the task.
Expand Down
1 change: 1 addition & 0 deletions src/A2A/Models/DataPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public class DataPart : Part
/// Structured data content.
/// </summary>
[JsonPropertyName("data")]
[JsonRequired]
public Dictionary<string, JsonElement> Data { get; set; } = [];
}
6 changes: 4 additions & 2 deletions src/A2A/Models/FileContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public class FileWithBytes : FileContent
/// base64 encoded content of the file.
/// </summary>
[JsonPropertyName("bytes")]
public string? Bytes { get; set; }
[JsonRequired]
public string Bytes { get; set; } = string.Empty;

/// <summary>
/// URL for the File content.
Expand Down Expand Up @@ -68,5 +69,6 @@ public class FileWithUri : FileContent
/// URL for the File content.
/// </summary>
[JsonPropertyName("uri")]
public string? Uri { get; set; }
[JsonRequired]
public string Uri { get; set; } = string.Empty;
}
3 changes: 2 additions & 1 deletion src/A2A/Models/FilePart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class FilePart : Part
/// File content either as url or bytes.
/// </summary>
[JsonPropertyName("file")]
public FileWithBytes File { get; set; } = new FileWithBytes();
[JsonRequired]
public FileContent File { get; set; } = new FileWithBytes();
}
2 changes: 1 addition & 1 deletion src/A2A/Models/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class Message : A2AResponse
/// </summary>
[JsonPropertyName("messageId")]
[JsonRequired]
public string? MessageId { get; set; }
public string MessageId { get; set; } = string.Empty;

/// <summary>
/// Identifier of task the message is related to.
Expand Down
3 changes: 2 additions & 1 deletion src/A2A/Models/MessageSendParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public class MessageSendConfiguration
/// Accepted output modalities by the client.
/// </summary>
[JsonPropertyName("acceptedOutputModes")]
public List<string>? AcceptedOutputModes { get; set; }
[JsonRequired]
public List<string> AcceptedOutputModes { get; set; } = [];

/// <summary>
/// Where the server should send notifications when disconnected.
Expand Down
Loading