├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug.yml │ ├── config.yml │ └── feature.yml ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── publish.yml │ └── test.yml ├── .gitignore ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MAINTAINERS.md ├── README.md ├── SECURITY.md ├── a2a-net.sln ├── samples ├── README.md └── semantic-kernel │ ├── README.md │ ├── a2a-net.Samples.SemanticKernel.Client │ ├── Configuration │ │ └── ApplicationOptions.cs │ ├── MessageExtensions.cs │ ├── PartExtensions.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Usings.cs │ └── a2a-net.Samples.SemanticKernel.Client.csproj │ ├── a2a-net.Samples.SemanticKernel.Server │ ├── Configuration │ │ ├── AgentKernelOptions.cs │ │ ├── AgentOptions.cs │ │ └── ApplicationOptions.cs │ ├── Extensions │ │ ├── IAsyncEnumerableExtensions.cs │ │ ├── MessageExtensions.cs │ │ └── PartExtensions.cs │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ └── AgentRuntime.cs │ ├── Usings.cs │ ├── a2a-net.Samples.SemanticKernel.Server.csproj │ ├── appsettings.Development.json │ └── appsettings.json │ └── a2a-net.Samples.SemanticKernel │ └── a2a-net.Samples.SemanticKernel.PushNotificationClient │ ├── Configuration │ └── ApplicationOptions.cs │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Usings.cs │ └── a2a-net.Samples.SemanticKernel.PushNotificationClient.csproj ├── src ├── a2a-net.Client.Asbtractions │ ├── Configuration │ │ └── A2AProtocolClientOptions.cs │ ├── Services │ │ └── Interfaces │ │ │ └── IA2AProtocolClient.cs │ ├── Usings.cs │ └── a2a-net.Client.Abstractions.csproj ├── a2a-net.Client.Http │ ├── Extensions │ │ ├── HttpRequestMessageExtensions.cs │ │ └── IServiceCollectionExtensions.cs │ ├── Services │ │ └── A2AProtocolHttpClient.cs │ ├── Usings.cs │ └── a2a-net.Client.Http.csproj ├── a2a-net.Client.WebSocket │ ├── Extensions │ │ └── IServiceCollectionExtensions.cs │ ├── Services │ │ └── A2AProtocolWebSocketClient.cs │ ├── Usings.cs │ └── a2a-net.Client.WebSocket.csproj ├── a2a-net.Client │ ├── A2ADiscoveryDocument.cs │ ├── A2ADiscoveryDocumentRequest.cs │ ├── Extensions │ │ └── HttpClientExtensions.cs │ ├── Usings.cs │ └── a2a-net.Client.csproj ├── a2a-net.Core │ ├── A2AProtocol.cs │ ├── Errors │ │ ├── InvalidParamsError.cs │ │ ├── InvalidRequestError.cs │ │ ├── PushNotificationNotSupportedError.cs │ │ ├── TaskNotFoundError.cs │ │ └── UnsupportedOperationError.cs │ ├── Events │ │ ├── TaskArtifactUpdateEvent.cs │ │ ├── TaskEvent.cs │ │ └── TaskStatusUpdateEvent.cs │ ├── IA2AProtocolService.cs │ ├── JsonRpcVersion.cs │ ├── MessageRole.cs │ ├── Models │ │ ├── AgentAuthentication.cs │ │ ├── AgentCapabilities.cs │ │ ├── AgentCard.cs │ │ ├── AgentProvider.cs │ │ ├── AgentSkill.cs │ │ ├── Artifact.cs │ │ ├── AuthenticationInfo.cs │ │ ├── DataPart.cs │ │ ├── File.cs │ │ ├── FilePart.cs │ │ ├── Message.cs │ │ ├── Part.cs │ │ ├── PushNotificationConfiguration.cs │ │ ├── RpcError.cs │ │ ├── Task.cs │ │ ├── TaskIdParameters.cs │ │ ├── TaskPushNotificationConfiguration.cs │ │ ├── TaskQueryParameters.cs │ │ ├── TaskSendParameters.cs │ │ ├── TaskStatus.cs │ │ └── TextPart.cs │ ├── PartType.cs │ ├── Requests │ │ ├── CancelTaskRequest.cs │ │ ├── GetTaskPushNotificationsRequest.cs │ │ ├── GetTaskRequest.cs │ │ ├── SendTaskRequest.cs │ │ ├── SendTaskStreamingRequest.cs │ │ ├── SetTaskPushNotificationsRequest.cs │ │ └── TaskResubscriptionRequest.cs │ ├── RpcEvent.cs │ ├── RpcMessage.cs │ ├── RpcRequest.cs │ ├── RpcResponse.cs │ ├── Serialization │ │ └── Json │ │ │ └── TaskEventJsonConverter.cs │ ├── TaskState.cs │ ├── Usings.cs │ └── a2a-net.Core.csproj ├── a2a-net.Server.AspNetCore │ ├── Extensions │ │ ├── A2AEndpointRouteBuilderExtensions.cs │ │ └── IApplicationBuilderExtensions.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ ├── A2AHttpMiddleware.cs │ │ └── A2AWebSocketMiddleware.cs │ ├── Usings.cs │ └── a2a-net.Server.AspNetCore.csproj ├── a2a-net.Server.Infrastructure.Abstractions │ ├── AgentResponseContent.cs │ ├── AgentResponseContentType.cs │ ├── Services │ │ ├── IA2AProtocolServer.cs │ │ ├── IA2AProtocolServerBuilder.cs │ │ ├── IA2AProtocolServerProvider.cs │ │ ├── IAgentCardBuilder.cs │ │ ├── IAgentProviderBuilder.cs │ │ ├── IAgentRuntime.cs │ │ ├── IAgentSkillBuilder.cs │ │ ├── IJsonWebKeySet.cs │ │ ├── IPushNotificationSender.cs │ │ ├── ITaskEventStream.cs │ │ ├── ITaskHandler.cs │ │ └── ITaskRepository.cs │ ├── TaskRecord.cs │ ├── Usings.cs │ └── a2a-net.Server.Infrastructure.Abstractions.csproj ├── a2a-net.Server.Infrastructure.DistributedCache │ ├── Extensions │ │ └── IA2AProtocolServerBuilderExtensions.cs │ ├── Services │ │ └── DistributedCacheTaskRepository.cs │ └── a2a-net.Server.Infrastructure.DistributedCache.csproj └── a2a-net.Server │ ├── Extensions │ ├── IServiceCollectionExtensions.cs │ └── TaskRecordExtensions.cs │ ├── Infrastructure │ └── Services │ │ ├── A2AProtocolServer.cs │ │ ├── A2AProtocolServerBuilder.cs │ │ ├── A2AProtocolServerProvider.cs │ │ ├── AgentCardBuilder.cs │ │ ├── AgentProviderBuilder.cs │ │ ├── AgentSkillBuilder.cs │ │ ├── JsonWebKeySet.cs │ │ ├── PushNotificationSender.cs │ │ ├── TaskEventStream.cs │ │ └── TaskHandler.cs │ ├── Usings.cs │ └── a2a-net.Server.csproj └── tests ├── a2a-net.IntegrationTests ├── A2AWebServerStartup.cs ├── Cases │ ├── A2ADiscoveryTests.cs │ └── A2AProtocolHttpClientTests.cs ├── Services │ ├── A2AWebServerFactory.cs │ ├── MockAgentRuntime.cs │ └── TestPushNotificationSender.cs ├── Usings.cs └── a2a-net.IntegrationTests.csproj └── a2a-net.UnitTests ├── Cases └── Serialization │ └── JsonSerializationTests.cs ├── Services ├── AuthenticationInfoFactory.cs ├── FileFactory.cs ├── MessageFactory.cs ├── MetadataFactory.cs ├── PartFactory.cs ├── PushNotificationConfigurationFactory.cs ├── TaskFactory.cs └── TaskStatusFactory.cs ├── Usings.cs └── a2a-net.UnitTests.csproj /.github/ISSUE_TEMPLATE/bug.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Create a bug report 3 | labels: ["bug"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | :pray: Thanks for taking the time to fill out this bug report! 9 | 10 | - type: markdown 11 | attributes: 12 | value: | 13 | ## Bug Report 14 | 15 | - type: textarea 16 | id: i-tried-this 17 | attributes: 18 | label: "I tried this:" 19 | placeholder: "What did you try to do? A code snippet or example helps." 20 | validations: 21 | required: true 22 | 23 | - type: textarea 24 | id: instead-what-happened 25 | attributes: 26 | label: "This happened:" 27 | placeholder: "What happened instead of what you've expected?" 28 | validations: 29 | required: true 30 | 31 | - type: textarea 32 | id: what-did-you-expect 33 | attributes: 34 | label: "I expected this:" 35 | placeholder: "What did you expect to happen? Describe the output or behavior you expected to see (unless it's obvious)." 36 | 37 | - type: textarea 38 | id: workaround 39 | attributes: 40 | label: "Is there a workaround?" 41 | placeholder: "What's the workaround to avoid this issue?" 42 | 43 | - type: textarea 44 | attributes: 45 | label: Anything else? 46 | placeholder: | 47 | Links? References? Logs? Anything that will give us more context about the issue you are encountering. 48 | Tip: You can attach images or log files by dragging files in. 49 | 50 | - type: markdown 51 | attributes: 52 | value: | 53 | ## Environment 54 | 55 | - type: dropdown 56 | id: platform 57 | attributes: 58 | label: "Platform(s)" 59 | multiple: true 60 | options: 61 | - MacOS 62 | - Linux 63 | - Windows 64 | - Other 65 | 66 | - type: textarea 67 | attributes: 68 | label: Community Notes 69 | value: | 70 | 71 | * Please vote by adding a 👍 reaction to the issue to help us prioritize. 72 | * If you are interested to work on this issue, please leave a comment.name: Bug Report 🐞 73 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: [] 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Create a feature request 3 | labels: ["enhancement"] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | :pray: Thanks for taking the time to fill out this feature request! 9 | 10 | - type: markdown 11 | attributes: 12 | value: | 13 | ## Feature Request 14 | 15 | - type: textarea 16 | id: what-would-you-like-to-be-added 17 | attributes: 18 | label: "What would you like to be added?" 19 | placeholder: "Description of the feature you'd like to see." 20 | validations: 21 | required: true 22 | 23 | - type: textarea 24 | id: proposals 25 | attributes: 26 | label: "Proposal(s):" 27 | placeholder: "Describe your proposal(s) and any relevant details here." 28 | 29 | - type: textarea 30 | id: alternatives 31 | attributes: 32 | label: "Alternative(s):" 33 | placeholder: "Describe any alternative approaches, options, or suggestions you’d like to consider." 34 | 35 | - type: textarea 36 | id: additional-info 37 | attributes: 38 | label: "Additional info:" 39 | placeholder: "Provide any supplementary details, context, or supporting information here." 40 | 41 | - type: textarea 42 | attributes: 43 | label: Community Notes 44 | value: | 45 | 46 | * Please vote by adding a 👍 reaction to the feature to help us prioritize. 47 | * If you are interested to work on this feature, please leave a comment. 48 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Many thanks for submitting your Pull Request :heart:!** 2 | 3 | **What this PR does / why we need it**: 4 | 5 | **Special notes for reviewers**: 6 | 7 | **Additional information (if needed):** -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | workflow_dispatch: 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | publish: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v3 18 | with: 19 | dotnet-version: | 20 | 8.0.x 21 | 9.0.x 22 | - name: Restore dependencies 23 | run: dotnet restore 24 | - name: Build 25 | run: dotnet build --configuration Release --no-restore 26 | - name: Publish Nuget Packages 27 | run: dotnet nuget push "./src/*/bin/Release/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate 28 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | paths-ignore: 7 | - '.github/**' 8 | - '**/*.md' 9 | - 'assets/**' 10 | pull_request: 11 | branches: [ main ] 12 | paths-ignore: 13 | - '.github/**' 14 | - '**/*.md' 15 | - 'assets/**' 16 | workflow_call: 17 | 18 | permissions: 19 | contents: read 20 | 21 | jobs: 22 | build-and-test: 23 | 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | - uses: actions/checkout@v3 28 | - name: Setup .NET 29 | uses: actions/setup-dotnet@v3 30 | with: 31 | dotnet-version: | 32 | 8.0.x 33 | 9.0.x 34 | - name: Restore dependencies 35 | run: dotnet restore 36 | - name: Build 37 | run: dotnet build --no-restore 38 | - name: Test 39 | run: dotnet test --no-build 40 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file provides an overview of code owners in this repository. 2 | 3 | # Each line is a file pattern followed by one or more owners. 4 | # The last matching pattern has the most precedence. 5 | # For more details, read the following article on GitHub: https://help.github.com/articles/about-codeowners/. 6 | 7 | # The default owners are automatically added as reviewers when you open a pull request unless different owners are specified in the file. 8 | 9 | * @cdavernas @jbbianchi -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | ## 🌐 A2A-NET Community Code of Conduct 4 | 5 | As contributors and maintainers of the A2A-NET solution, we pledge to foster a community that is: 6 | 7 | - 🛠️ **Inclusive** 8 | - 📚 **Respectful** 9 | - 💬 **Constructive** 10 | - 🤝 **Collaborative** 11 | 12 | We believe innovation thrives in environments where everyone feels safe, heard, and empowered. 13 | 14 | --- 15 | 16 | ## 💡 Our Standards 17 | 18 | All participants in this community — contributors, users, reviewers, maintainers — are expected to: 19 | 20 | - ✅ Use welcoming and inclusive language 21 | - ✅ Be respectful of differing viewpoints and experiences 22 | - ✅ Gracefully accept constructive feedback 23 | - ✅ Focus on what is best for the project and the community 24 | - ✅ Show empathy toward others 25 | 26 | --- 27 | 28 | ## 🚫 Unacceptable Behavior 29 | 30 | Examples of unacceptable behavior include: 31 | 32 | - ❌ Harassment, abuse, or discrimination of any kind 33 | - ❌ Trolling, insulting or derogatory comments 34 | - ❌ Publishing others' private information (doxxing) 35 | - ❌ Disruptive conduct that hinders collaboration 36 | 37 | --- 38 | 39 | ## 📣 Reporting Issues 40 | 41 | If you witness or experience unacceptable behavior, please report it confidentially: 42 | 43 | 📧 **Email**: info@neuroglia.io 44 | 45 | All reports will be reviewed and investigated promptly and fairly. We will respect confidentiality and act in the best interest of community safety. 46 | 47 | --- 48 | 49 | ## ⚖️ Enforcement 50 | 51 | Community maintainers are responsible for enforcing this code of conduct. They may take any action they deem appropriate, including: 52 | 53 | - Warnings 54 | - Temporary or permanent bans 55 | - Removal of contributions 56 | 57 | --- 58 | 59 | ## 🙌 Attribution 60 | 61 | This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1. 62 | 63 | --- 64 | 65 | We strive to build not just a powerful agentic orchestration system, but a community as thoughtful and adaptive as the agents it empowers. 66 | 67 | **— The A2A-NET Team** 68 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 👥 Contributing to `akordai/net-sdk` 2 | 3 | Thanks for your interest in contributing to [A2A-NET](https://github.com/neuroglia-io/a2a-net). 4 | 5 | Whether you're fixing bugs, improving documentation, or implementing new capabilities — we appreciate your help! 6 | 7 | --- 8 | 9 | ## 🚀 Getting Started 10 | 11 | 1. **Fork the repository** 12 | 2. **Clone your fork** 13 | ```bash 14 | git clone https://github.com/YOUR-USERNAME/net-sdk 15 | cd net-sdk 16 | ``` 17 | 18 | 3. **Set up dependencies** 19 | ```bash 20 | dotnet restore 21 | ``` 22 | 23 | 4. **Build the solution** 24 | ```bash 25 | dotnet build 26 | ``` 27 | 28 | 5. **Run tests** 29 | ```bash 30 | dotnet test 31 | ``` 32 | 33 | --- 34 | 35 | ## 🧠 Guidelines 36 | 37 | ### ✅ Do 38 | 39 | - Use clear, self-explanatory commit messages 40 | - Follow C# conventions 41 | - Add or update unit/integration tests when applicable 42 | - Write or improve XML `` docs for public types and members 43 | 44 | ### ❌ Don’t 45 | 46 | - Introduce breaking changes without discussion 47 | - Leave `TODO` comments in committed code 48 | - Reformat unrelated files in the same PR 49 | 50 | --- 51 | 52 | ## 💡 Feature Contributions 53 | 54 | 1. Open an issue or discussion to validate your idea 55 | 2. Fork and branch from `main` 56 | 3. Create a descriptive PR — include context, screenshots, YAML examples if relevant 57 | 58 | --- 59 | 60 | ## 🧪 Testing 61 | 62 | All PRs must pass unit tests and schema validation. We're actively adding more test coverage — feel free to contribute! 63 | 64 | --- 65 | 66 | ## 📚 Documentation 67 | 68 | Public APIs, YAML schemas, and DSL syntax should be documented in: 69 | 70 | - XML comments (``, etc.) 71 | - Markdown files in `/docs` 72 | - Example YAML snippets under `/samples` 73 | 74 | --- 75 | 76 | ## 🛡️ Code of Conduct 77 | 78 | We are committed to a respectful and inclusive environment. Please read our [Code of Conduct](./CODE_OF_CONDUCT.md) before contributing. 79 | 80 | --- 81 | 82 | ## 🙏 Thank You 83 | 84 | You're helping shape a modular, open foundation for agent orchestration in AI-native applications. We’re grateful you're here. 85 | 86 | — The A2A-NET Team 87 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # A2A-NET Maintainers 2 | 3 | * [Charles d'Avernas](https://github.com/cdavernas) 4 | * [Jean-Baptiste Bianchi](https://github.com/JBBianchi) 5 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | The [A2A NET SDK](https://github.com/neuroglia-io/a2a-net) team and community take security vulnerabilities very seriously. Responsible disclosure of security issues is greatly appreciated, and every effort will be made to acknowledge and address your findings. 6 | 7 | To report a security issue: 8 | 9 | - **Use the GitHub Security Advisory**: Please use the ["Report a Vulnerability"](https://github.com/neuroglia-io/a2a-net/security/advisories/new) tab on GitHub to submit your report. 10 | 11 | The team will acknowledge your report and provide details on the next steps. After the initial response, the security team will keep you informed of the progress towards a fix and any subsequent announcements. Additional information or guidance may be requested as necessary. 12 | 13 | ## Security Best Practices 14 | 15 | To ensure the security and stability of the [A2A NET SDK](https://github.com/neuroglia-io/a2a-net), consider the following best practices: 16 | 17 | - **Runtime Environment Hardening**: Secure the underlying infrastructure where the SDK is used. This includes using up-to-date operating systems, applying security patches regularly, and configuring firewalls and security groups to limit access to only necessary ports and services. 18 | 19 | - **Secure Configuration Management**: Ensure that configuration files, especially those containing sensitive information like API keys, connection strings, or certificates, are stored securely. Use environment variables, secret management tools, or configuration providers to avoid hardcoding sensitive data in your application. 20 | 21 | - **Dependency Management**: Regularly audit and update dependencies used in your project. Use tools like [Dependabot](https://github.com/dependabot) or similar dependency management solutions to identify vulnerabilities in third-party NuGet packages and address them promptly. 22 | 23 | By adhering to these best practices, the security of workflows and applications built using the [A2A NET SDK](https://github.com/neuroglia-io/a2a-net) can be significantly enhanced, reducing the risk of vulnerabilities and ensuring the integrity and reliability of the workflows executed. 24 | 25 | --- 26 | 27 | Thank you for contributing to the security and integrity of the [A2A NET SDK](https://github.com/neuroglia-io/a2a-net)! 28 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | # 🧪 Samples 2 | 3 | Welcome to the `samples/` directory! 4 | This folder contains example projects that demonstrate how to use [a2a-net](#) to build, expose, and consume AI agents using the [Agent-to-Agent (A2A)](https://google.github.io/A2A/) protocol. 5 | 6 | ## 📦 Available Samples 7 | 8 | - [Semantic Kernel](/samples/semantic-kernel/) 9 | Demonstrates how to build and host an A2A-compatible agent using [Microsoft's Semantic Kernel](https://aka.ms/semantic-kernel) and OpenAI. 10 | Includes: 11 | - a server that hosts the agent and exposes it via A2A and HTTP endpoints 12 | - a client that connects to the agent using the JSON-RPC protocol over HTTP 13 | - a clientt used to consume push notifications -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Client/Configuration/ApplicationOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Samples.SemanticKernel.Client.Configuration 15 | { 16 | /// 17 | /// Represents the options used to configure the application 18 | /// 19 | public class ApplicationOptions 20 | { 21 | /// 22 | /// Gets/sets the URI of the A2A server to interact with 23 | /// 24 | [Required] 25 | public Uri? Server { get; set; } = null; 26 | 27 | /// 28 | /// Gets/sets the URI, if any, of the endpoint to send push notifications to 29 | /// 30 | public Uri? PushNotificationClient { get; set; } 31 | 32 | /// 33 | /// Gets or sets a value indicating whether streaming is enabled 34 | /// 35 | public bool Streaming { get; set; } 36 | 37 | /// 38 | /// Gets or sets the authentication token or mechanism 39 | /// 40 | public string? Auth { get; set; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Client/MessageExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using System.Text; 15 | 16 | namespace A2A.Samples.SemanticKernel.Client; 17 | 18 | /// 19 | /// Defines extensions for s 20 | /// 21 | public static class MessageExtensions 22 | { 23 | 24 | /// 25 | /// Converts the into text 26 | /// 27 | /// The to convert 28 | /// The converted 29 | public static string? ToText(this Message message) 30 | { 31 | ArgumentNullException.ThrowIfNull(message); 32 | if (message.Parts == null) return null; 33 | var textBuilder = new StringBuilder(); 34 | foreach (var part in message.Parts) textBuilder.Append(part.ToText()); 35 | return textBuilder.ToString(); 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Client/PartExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using System.Text; 15 | using System.Text.Json; 16 | 17 | namespace A2A.Samples.SemanticKernel.Client; 18 | 19 | /// 20 | /// Defines extensions for s 21 | /// 22 | public static class PartExtensions 23 | { 24 | 25 | /// 26 | /// Converts the into text 27 | /// 28 | /// The to convert 29 | /// The converted 30 | public static string ToText(this Part part) 31 | { 32 | ArgumentNullException.ThrowIfNull(part); 33 | switch (part) 34 | { 35 | case TextPart textPart: 36 | return textPart.Text; 37 | case FilePart filePart: 38 | var fileContentBuilder = new StringBuilder(); 39 | fileContentBuilder.AppendLine("----- FILE -----"); 40 | if (!string.IsNullOrWhiteSpace(filePart.File.Name)) fileContentBuilder.AppendLine($"Name : {filePart.File.Name}"); 41 | if (!string.IsNullOrWhiteSpace(filePart.File.MimeType)) fileContentBuilder.AppendLine($"MIME : {filePart.File.MimeType}"); 42 | if (!string.IsNullOrWhiteSpace(filePart.File.Bytes)) fileContentBuilder.AppendLine($"Size : {Convert.FromBase64String(filePart.File.Bytes).Length}"); 43 | else if (filePart.File.Uri is not null) fileContentBuilder.AppendLine($"URI : {filePart.File.Uri}"); 44 | fileContentBuilder.AppendLine("----------------"); 45 | return fileContentBuilder.ToString(); 46 | case DataPart dataPart: 47 | var jsonContentBuilder = new StringBuilder(); 48 | jsonContentBuilder.AppendLine("```json"); 49 | jsonContentBuilder.AppendLine(JsonSerializer.Serialize(dataPart.Data)); 50 | jsonContentBuilder.AppendLine("```"); 51 | return jsonContentBuilder.ToString(); 52 | default: 53 | throw new NotSupportedException($"The specified part type '{part.Type ?? "None"}' is not supported"); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Client/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Synchronous client": { 4 | "commandName": "Project", 5 | "commandLineArgs": "--Server http://localhost:5079 --PushNotificationClient http://localhost:5198", 6 | "environmentVariables": { 7 | "DOTNET_ENVIRONMENT": "Development" 8 | } 9 | }, 10 | "Streaming client": { 11 | "commandName": "Project", 12 | "commandLineArgs": "--Server http://localhost:5079 --PushNotificationClient http://localhost:5198 --streaming", 13 | "environmentVariables": { 14 | "DOTNET_ENVIRONMENT": "Development" 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Client/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A; 15 | global using A2A.Client; 16 | global using A2A.Client.Services; 17 | global using A2A.Models; 18 | global using A2A.Requests; 19 | global using A2A.Samples.SemanticKernel.Client.Configuration; 20 | global using Microsoft.Extensions.Configuration; 21 | global using Microsoft.Extensions.DependencyInjection; 22 | global using Spectre.Console; 23 | global using System.ComponentModel.DataAnnotations; 24 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Client/a2a-net.Samples.SemanticKernel.Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net9.0 6 | A2A.Samples.SemanticKernel.Client 7 | enable 8 | enable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/Configuration/AgentKernelOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Samples.SemanticKernel.Server.Configuration; 15 | 16 | /// 17 | /// Represents the options used to configure the agent's 18 | /// 19 | public class AgentKernelOptions 20 | { 21 | 22 | /// 23 | /// Gets/sets the id of the model used by the application's 24 | /// 25 | [Required, MinLength(1)] 26 | public virtual string Model { get; set; } = "gpt-4o"; 27 | 28 | /// 29 | /// Gets/sets the API key used to authenticate on the chat completion API used by the application's 30 | /// 31 | [Required, MinLength(1)] 32 | public virtual string ApiKey { get; set; } = null!; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/Configuration/AgentOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Samples.SemanticKernel.Server.Configuration; 15 | 16 | /// 17 | /// Represents the options used to configure the application's agent 18 | /// 19 | public class AgentOptions 20 | { 21 | 22 | /// 23 | /// Gets/sets the name of the application's AI agent 24 | /// 25 | [Required, MinLength(1)] 26 | public virtual string Name { get; set; } = null!; 27 | 28 | /// 29 | /// Gets/sets the description, if any, of the application's AI agent 30 | /// 31 | public virtual string? Description { get; set; } 32 | 33 | /// 34 | /// Gets/sets the version of the application's AI agent 35 | /// 36 | [Required, MinLength(1)] 37 | public virtual string Version { get; set; } = null!; 38 | 39 | /// 40 | /// Gets/sets the agent's instructions, if any 41 | /// 42 | public virtual string? Instructions { get; set; } 43 | 44 | /// 45 | /// Gets/sets a list containing the skills, if any, of the application's AI agent 46 | /// 47 | public virtual List? Skills { get; set; } 48 | 49 | /// 50 | /// Gets/sets the options used to configure the agent's 51 | /// 52 | [Required] 53 | public virtual AgentKernelOptions Kernel { get; set; } = null!; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/Configuration/ApplicationOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Samples.SemanticKernel.Server.Configuration; 15 | 16 | /// 17 | /// Represents the options used to configure the application 18 | /// 19 | public class ApplicationOptions 20 | { 21 | 22 | /// 23 | /// Gets/sets the options used to configure the application's AI agent 24 | /// 25 | [Required] 26 | public virtual AgentOptions Agent { get; set; } = null!; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/Extensions/IAsyncEnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Samples.SemanticKernel.Server; 15 | 16 | /// 17 | /// Defines extensions for instances 18 | /// 19 | public static class IAsyncEnumerableExtensions 20 | { 21 | 22 | /// 23 | /// Enumerates the elements of an while providing a lookahead to the next item. 24 | /// Useful for scenarios where you need to detect the final iteration or inspect the upcoming element. 25 | /// 26 | /// The type of the elements in the source sequence. 27 | /// The source asynchronous enumerable to iterate. 28 | /// A token to cancel the enumeration operation. 29 | /// 30 | /// An of tuples, where each tuple contains the current item and the next item (or default if at the end of the sequence). 31 | /// 32 | public static async IAsyncEnumerable<(T current, T? next)> PeekingAsync(this IAsyncEnumerable source, [EnumeratorCancellation] CancellationToken cancellationToken = default) 33 | { 34 | await using var enumerator = source.GetAsyncEnumerator(cancellationToken); 35 | if (!await enumerator.MoveNextAsync()) yield break; 36 | var current = enumerator.Current; 37 | while (await enumerator.MoveNextAsync()) 38 | { 39 | yield return (current, enumerator.Current); 40 | current = enumerator.Current; 41 | } 42 | yield return (current, default); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/Extensions/MessageExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Samples.SemanticKernel.Server; 15 | 16 | /// 17 | /// Defines extensions for s 18 | /// 19 | public static class MessageExtensions 20 | { 21 | 22 | /// 23 | /// Converts the into text 24 | /// 25 | /// The to convert 26 | /// The converted 27 | public static string? ToText(this Message message) 28 | { 29 | ArgumentNullException.ThrowIfNull(message); 30 | if (message.Parts == null) return null; 31 | var textBuilder = new StringBuilder(); 32 | foreach (var part in message.Parts) textBuilder.AppendLine(part.ToText()); 33 | return textBuilder.ToString(); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/Extensions/PartExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Samples.SemanticKernel.Server; 15 | 16 | /// 17 | /// Defines extensions for s 18 | /// 19 | public static class PartExtensions 20 | { 21 | 22 | /// 23 | /// Converts the into text 24 | /// 25 | /// The to convert 26 | /// The converted 27 | public static string ToText(this Part part) 28 | { 29 | ArgumentNullException.ThrowIfNull(part); 30 | switch (part) 31 | { 32 | case TextPart textPart: 33 | return textPart.Text; 34 | case FilePart filePart: 35 | var fileContentBuilder = new StringBuilder(); 36 | fileContentBuilder.AppendLine("----- FILE -----"); 37 | if (!string.IsNullOrWhiteSpace(filePart.File.Name)) fileContentBuilder.AppendLine($"Name : {filePart.File.Name}"); 38 | if (!string.IsNullOrWhiteSpace(filePart.File.MimeType)) fileContentBuilder.AppendLine($"MIME : {filePart.File.MimeType}"); 39 | if (!string.IsNullOrWhiteSpace(filePart.File.Bytes)) fileContentBuilder.AppendLine($"Base64 : {filePart.File.Bytes}"); 40 | else if (filePart.File.Uri is not null) fileContentBuilder.AppendLine($"URI : {filePart.File.Uri}"); 41 | fileContentBuilder.AppendLine("----------------"); 42 | return fileContentBuilder.ToString(); 43 | case DataPart dataPart: 44 | var jsonContentBuilder = new StringBuilder(); 45 | jsonContentBuilder.AppendLine("```json"); 46 | jsonContentBuilder.AppendLine(JsonSerializer.Serialize(dataPart.Data)); 47 | jsonContentBuilder.AppendLine("```"); 48 | return jsonContentBuilder.ToString(); 49 | default: 50 | throw new NotSupportedException($"The specified part type '{part.Type ?? "None"}' is not supported"); 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "http": { 5 | "commandName": "Project", 6 | "dotnetRunMessages": true, 7 | "launchBrowser": true, 8 | "applicationUrl": "http://localhost:5079", 9 | "environmentVariables": { 10 | "ASPNETCORE_ENVIRONMENT": "Development" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Models; 15 | global using A2A.Samples.SemanticKernel.Server.Configuration; 16 | global using A2A.Samples.SemanticKernel.Server.Services; 17 | global using A2A.Server; 18 | global using A2A.Server.AspNetCore; 19 | global using A2A.Server.Infrastructure; 20 | global using A2A.Server.Infrastructure.Services; 21 | global using Microsoft.AspNetCore.Mvc; 22 | global using Microsoft.Extensions.Options; 23 | global using Microsoft.SemanticKernel; 24 | global using Microsoft.SemanticKernel.ChatCompletion; 25 | global using Neuroglia; 26 | global using System.Collections.Concurrent; 27 | global using System.ComponentModel.DataAnnotations; 28 | global using System.Runtime.CompilerServices; 29 | global using System.Text; 30 | global using System.Text.Json; 31 | global using System.Text.Json.Serialization; 32 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/a2a-net.Samples.SemanticKernel.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | A2A.Samples.SemanticKernel.Server 8 | 7ae06787-a72b-4029-abe1-4afcad6ccdcb 9 | 10 | 11 | 12 | $(NoWarn);CA2007;IDE1006;SKEXP0001;SKEXP0010;SKEXP0070;SKEXP0110;OPENAI001 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "Agent": { 10 | "Name": "SampleAgent", 11 | "Description": "An AI agent that uses OpenAI and Semantic Kernel to perform general-purpose reasoning and content generation tasks", 12 | "Version": "1.0.0", 13 | "Instructions": "You are an intelligent and articulate assistant designed to help users reason through problems and generate high-quality content. \nYou can respond to questions, summarize information, provide explanations, brainstorm ideas, and produce clear, well-structured text across a wide variety of topics. \nAlways aim to be helpful, concise, and context-aware. When appropriate, ask clarifying questions to better assist the user. Ensure factual accuracy and clear communication in every response.", 14 | "Kernel": { 15 | "Model": "gpt-4o" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel/a2a-net.Samples.SemanticKernel.PushNotificationClient/Configuration/ApplicationOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace a2a_net.Samples.SemanticKernel.PushNotificationClient.Configuration; 15 | 16 | /// 17 | /// Represents the options used to configure the application 18 | /// 19 | public class ApplicationOptions 20 | { 21 | 22 | /// 23 | /// Gets/sets the remote server's URI 24 | /// 25 | public required Uri Server { get; set; } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel/a2a-net.Samples.SemanticKernel.PushNotificationClient/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | var builder = WebApplication.CreateBuilder(args); 15 | builder.Services.AddOptions().Bind(builder.Configuration).ValidateDataAnnotations().ValidateOnStart(); 16 | builder.Services.AddHttpClient(); 17 | var app = builder.Build(); 18 | 19 | const string jwksPath = ".well-known/jwks.json"; 20 | 21 | app.MapGet("/", (HttpRequest request) => 22 | { 23 | if (request.Query.TryGetValue("validationToken", out var token)) return Results.Text(token); 24 | else return Results.BadRequest("Missing validationToken query param"); 25 | }); 26 | app.MapPost("/", async (HttpRequest request, HttpClient httpClient, IOptions options) => 27 | { 28 | var jwksUri = new UriBuilder(options.Value.Server); 29 | if (jwksUri.Uri.IsAbsoluteUri) 30 | { 31 | jwksUri.Query = request.QueryString.Value ?? httpClient.BaseAddress?.Query; 32 | jwksUri.Path = $"{jwksUri.Path.TrimEnd('/')}/{jwksPath}"; 33 | } 34 | 35 | var json = await httpClient.GetStringAsync(jwksUri.Uri, request.HttpContext.RequestAborted); 36 | var jwks = new JsonWebKeySet(json); 37 | using var reader = new StreamReader(request.Body); 38 | var payload = await reader.ReadToEndAsync(request.HttpContext.RequestAborted); 39 | var token = request.Headers.Authorization.ToString()["Bearer ".Length..].Trim(); 40 | var tokenHandler = new JsonWebTokenHandler(); 41 | var result = await tokenHandler.ValidateTokenAsync(token, new TokenValidationParameters 42 | { 43 | ValidateIssuer = false, 44 | ValidateAudience = false, 45 | RequireSignedTokens = true, 46 | ValidateLifetime = true, 47 | IssuerSigningKeys = jwks.GetSigningKeys(), 48 | ValidAlgorithms = [SecurityAlgorithms.RsaSha256], 49 | RequireExpirationTime = false 50 | }); 51 | if (result.IsValid) return Results.Ok(); 52 | else return Results.Forbid(); 53 | }); 54 | 55 | await app.RunAsync(); 56 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel/a2a-net.Samples.SemanticKernel.PushNotificationClient/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "profiles": { 4 | "http": { 5 | "commandName": "Project", 6 | "dotnetRunMessages": true, 7 | "applicationUrl": "http://localhost:5198", 8 | "environmentVariables": { 9 | "ASPNETCORE_ENVIRONMENT": "Development", 10 | "SERVER": "http://localhost:5079" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel/a2a-net.Samples.SemanticKernel.PushNotificationClient/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using a2a_net.Samples.SemanticKernel.PushNotificationClient.Configuration; 15 | global using Microsoft.Extensions.Options; 16 | global using Microsoft.IdentityModel.JsonWebTokens; 17 | global using Microsoft.IdentityModel.Tokens; 18 | -------------------------------------------------------------------------------- /samples/semantic-kernel/a2a-net.Samples.SemanticKernel/a2a-net.Samples.SemanticKernel.PushNotificationClient/a2a-net.Samples.SemanticKernel.PushNotificationClient.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | a2a_net.Samples.SemanticKernel.PushNotificationClient 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/a2a-net.Client.Asbtractions/Configuration/A2AProtocolClientOptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Client.Configuration; 15 | 16 | /// 17 | /// Represents the options used to configure an A2A client. 18 | /// 19 | public class A2AProtocolClientOptions 20 | { 21 | /// 22 | /// Gets or sets the that references the endpoint of the A2A server to use. 23 | /// 24 | public virtual Uri Endpoint { get; set; } = null!; 25 | 26 | /// 27 | /// Gets or sets a function that produces the authorization scheme and token used to authenticate requests. 28 | /// 29 | /// 30 | /// The returned tuple should contain: 31 | /// 32 | /// 33 | /// Scheme (e.g., "Bearer") 34 | /// 35 | /// 36 | /// Token (the corresponding token string) 37 | /// 38 | /// 39 | /// If this property is null, no authorization header is applied. 40 | /// 41 | public virtual Func<(string Scheme, string Token)>? Authorization { get; set; } = null; 42 | } 43 | -------------------------------------------------------------------------------- /src/a2a-net.Client.Asbtractions/Services/Interfaces/IA2AProtocolClient.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Client.Services; 15 | 16 | /// 17 | /// Defines the fundamentals of a client implementation 18 | /// 19 | public interface IA2AProtocolClient 20 | : IA2AProtocolService, IDisposable 21 | { 22 | 23 | 24 | 25 | } -------------------------------------------------------------------------------- /src/a2a-net.Client.Asbtractions/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using Microsoft.Extensions.DependencyInjection; 15 | global using Microsoft.Extensions.Logging; 16 | global using A2A.Client.Services; 17 | global using A2A.Events; 18 | global using A2A.Models; 19 | global using A2A.Requests; 20 | global using StreamJsonRpc; 21 | global using System.Runtime.CompilerServices; 22 | -------------------------------------------------------------------------------- /src/a2a-net.Client.Asbtractions/a2a-net.Client.Abstractions.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.Client 8 | 0.8.0 9 | $(VersionPrefix) 10 | $(VersionPrefix) 11 | en 12 | true 13 | True 14 | true 15 | A2A-NET Protocol Client 16 | Contains the A2A Protocol client abstractions 17 | a2a;client;abstractions 18 | true 19 | Apache-2.0 20 | README.md 21 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 22 | https://github.com/neuroglia-io/a2a 23 | https://github.com/neuroglia-io/a2a 24 | git 25 | embedded 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/a2a-net.Client.Http/Extensions/HttpRequestMessageExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Client; 15 | 16 | /// 17 | /// Defines extensions for s 18 | /// 19 | public static class HttpRequestMessageExtensions 20 | { 21 | 22 | /// 23 | /// Enables Web Assembly streaming response for the specified 24 | /// 25 | /// The to enable Web Assembly streaming response for 26 | public static void EnableWebAssemblyStreamingResponse(this HttpRequestMessage request) => request.Options.Set(new("WebAssemblyEnableStreamingResponse"), true); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/a2a-net.Client.Http/Extensions/IServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Client; 15 | 16 | /// 17 | /// Defines extensions for s 18 | /// 19 | public static class IServiceCollectionExtensions 20 | { 21 | 22 | /// 23 | /// Adds and configures a new A2A protocol HTTP client 24 | /// 25 | /// The to configure 26 | /// An used to configure the to use 27 | /// The configured 28 | public static IServiceCollection AddA2AProtocolHttpClient(this IServiceCollection services, Action setup) 29 | { 30 | services.Configure(setup); 31 | services.AddHttpClient(); 32 | return services; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/a2a-net.Client.Http/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Client.Configuration; 15 | global using A2A.Client.Services; 16 | global using A2A.Events; 17 | global using A2A.Models; 18 | global using A2A.Requests; 19 | global using Microsoft.Extensions.DependencyInjection; 20 | global using Microsoft.Extensions.Options; 21 | global using System.Net.Http.Json; 22 | global using System.Net.Mime; 23 | global using System.Runtime.CompilerServices; 24 | global using System.Text; 25 | global using System.Text.Json; 26 | -------------------------------------------------------------------------------- /src/a2a-net.Client.Http/a2a-net.Client.Http.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.Client 8 | 0.8.0 9 | $(VersionPrefix) 10 | $(VersionPrefix) 11 | en 12 | true 13 | True 14 | true 15 | A2A-NET Protocol HTTP Client 16 | Contains the A2A Protocol HTTP client 17 | a2a;client;http 18 | true 19 | Apache-2.0 20 | README.md 21 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 22 | https://github.com/neuroglia-io/a2a 23 | https://github.com/neuroglia-io/a2a 24 | git 25 | embedded 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/a2a-net.Client.WebSocket/Extensions/IServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Client; 15 | 16 | /// 17 | /// Defines extensions for s 18 | /// 19 | public static class IServiceCollectionExtensions 20 | { 21 | 22 | /// 23 | /// Adds and configures a new A2A protocol HTTP client 24 | /// 25 | /// The to configure 26 | /// An used to configure the to use 27 | /// The configured 28 | public static IServiceCollection AddA2AProtocolWebSocketClient(this IServiceCollection services, Action setup) 29 | { 30 | services.Configure(setup); 31 | services.AddTransient(); 32 | return services; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/a2a-net.Client.WebSocket/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Client.Configuration; 15 | global using A2A.Client.Services; 16 | global using A2A.Client.Transport.WebSocket.Services; 17 | global using A2A.Events; 18 | global using A2A.Models; 19 | global using A2A.Requests; 20 | global using Microsoft.Extensions.DependencyInjection; 21 | global using Microsoft.Extensions.Logging; 22 | global using Microsoft.Extensions.Options; 23 | global using StreamJsonRpc; 24 | global using System.Net.WebSockets; 25 | global using System.Runtime.CompilerServices; 26 | -------------------------------------------------------------------------------- /src/a2a-net.Client.WebSocket/a2a-net.Client.WebSocket.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.Client.WebSocket 8 | 0.8.0 9 | $(VersionPrefix) 10 | $(VersionPrefix) 11 | en 12 | true 13 | True 14 | true 15 | A2A-NET Protocol WebSocket Client 16 | Contains the A2A Protocol WebSocket client 17 | a2a;client;websocket 18 | true 19 | Apache-2.0 20 | README.md 21 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 22 | https://github.com/neuroglia-io/a2a 23 | https://github.com/neuroglia-io/a2a 24 | git 25 | embedded 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/a2a-net.Client/A2ADiscoveryDocument.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Client; 15 | 16 | /// 17 | /// Represents the result of an A2A agent discovery operation 18 | /// 19 | public class A2ADiscoveryDocument 20 | { 21 | 22 | /// 23 | /// Gets the endpoint from which the discovery document was retrieved 24 | /// 25 | public virtual required Uri Endpoint { get; init; } 26 | 27 | /// 28 | /// Gets a list contained the discovered entries returned by the remote agent 29 | /// 30 | public virtual required IReadOnlyList Agents { get; init; } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/a2a-net.Client/A2ADiscoveryDocumentRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Client; 15 | 16 | /// 17 | /// Represents a request to retrieve an A2A discovery document from a remote server 18 | /// 19 | public class A2ADiscoveryDocumentRequest 20 | { 21 | 22 | /// 23 | /// Gets/sets the base URI of the remote server to query for discovery metadata 24 | /// 25 | public virtual Uri? Address { get; init; } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/a2a-net.Client/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Models; 15 | global using System.Net; 16 | global using System.Net.Http.Headers; 17 | global using System.Net.Http.Json; 18 | global using System.Net.Mime; 19 | global using System.Text; 20 | global using System.Text.Json; -------------------------------------------------------------------------------- /src/a2a-net.Client/a2a-net.Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.Client 8 | 0.8.0 9 | $(VersionPrefix) 10 | $(VersionPrefix) 11 | en 12 | true 13 | True 14 | true 15 | A2A-NET Protocol Client 16 | Contains the A2A Protocol client 17 | a2a;client 18 | true 19 | Apache-2.0 20 | README.md 21 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 22 | https://github.com/neuroglia-io/a2a 23 | https://github.com/neuroglia-io/a2a 24 | git 25 | embedded 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Errors/InvalidParamsError.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Errors; 15 | 16 | /// 17 | /// Represents an error that occurs when the parameters of a request are invalid or fail validation 18 | /// 19 | [DataContract] 20 | public record InvalidParamsError() 21 | : RpcError(ErrorCode, "Invalid parameters") 22 | { 23 | 24 | /// 25 | /// Gets the error code associated with the 26 | /// 27 | public const int ErrorCode = -32600; 28 | 29 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Errors/InvalidRequestError.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Errors; 15 | 16 | /// 17 | /// Represents an error that occurs when the request payload is invalid or fails validation 18 | /// 19 | [DataContract] 20 | public record InvalidRequestError() 21 | : RpcError(ErrorCode, "Request payload validation error") 22 | { 23 | 24 | /// 25 | /// Gets the error code associated with the 26 | /// 27 | public const int ErrorCode = -32600; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Errors/PushNotificationNotSupportedError.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Errors; 15 | 16 | /// 17 | /// Represents an error that occurs when attempting to perform push notification related operations on a server that does not support them 18 | /// 19 | [DataContract] 20 | public record PushNotificationNotSupportedError() 21 | : RpcError(ErrorCode, "Push Notification is not supported") 22 | { 23 | 24 | /// 25 | /// Gets the error code associated with the 26 | /// 27 | public const int ErrorCode = -32003; 28 | 29 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Errors/TaskNotFoundError.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Errors; 15 | 16 | /// 17 | /// Represents an error indicating that the specified task could not be found 18 | /// 19 | [DataContract] 20 | public record TaskNotFoundError() 21 | : RpcError(ErrorCode, "Task not found") 22 | { 23 | 24 | /// 25 | /// Gets the error code associated with the 26 | /// 27 | public const int ErrorCode = -32001; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Errors/UnsupportedOperationError.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Errors; 15 | 16 | /// 17 | /// Represents an error indicating that the specified operation is not supported 18 | /// 19 | [DataContract] 20 | public record UnsupportedOperationError() 21 | : RpcError(ErrorCode, "This operation is not supported") 22 | { 23 | 24 | /// 25 | /// Gets the error code associated with the 26 | /// 27 | public const int ErrorCode = -32004; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Events/TaskArtifactUpdateEvent.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Events; 15 | 16 | /// 17 | /// Represents the event used to notify about an artifact update 18 | /// 19 | [DataContract] 20 | public record TaskArtifactUpdateEvent 21 | : TaskEvent 22 | { 23 | 24 | /// 25 | /// Gets/sets the updated artifact 26 | /// 27 | [Required] 28 | [DataMember(Name = "artifact", Order = 1), JsonPropertyName("artifact"), JsonPropertyOrder(1), YamlMember(Alias = "artifact", Order = 1)] 29 | public virtual Artifact Artifact { get; set; } = null!; 30 | 31 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Events/TaskEvent.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Events; 15 | 16 | /// 17 | /// Represents the base class for all task-related RPC events 18 | /// 19 | [DataContract] 20 | [JsonConverter(typeof(TaskEventJsonConverter))] 21 | public abstract record TaskEvent 22 | : RpcEvent 23 | { 24 | 25 | /// 26 | /// Gets/sets the task's unique identifier 27 | /// 28 | [Required, MinLength(1)] 29 | [DataMember(Name = "id", Order = 0), JsonPropertyName("id"), JsonPropertyOrder(0), YamlMember(Alias = "id", Order = 0)] 30 | public virtual string Id { get; set; } = null!; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Events/TaskStatusUpdateEvent.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Events; 15 | 16 | /// 17 | /// Represents the event used to notify about a status update 18 | /// 19 | [DataContract] 20 | public record TaskStatusUpdateEvent 21 | : TaskEvent 22 | { 23 | 24 | /// 25 | /// Gets/sets the task's status 26 | /// 27 | [Required] 28 | [DataMember(Name = "status", Order = 1), JsonPropertyName("status"), JsonPropertyOrder(1), YamlMember(Alias = "status", Order = 1)] 29 | public virtual Models.TaskStatus Status { get; set; } = null!; 30 | 31 | /// 32 | /// Gets/sets a boolean indicating whether or not the event is the last of the stream it belongs to 33 | /// 34 | [DataMember(Name = "final", Order = 2), JsonPropertyName("final"), JsonPropertyOrder(2), YamlMember(Alias = "final", Order = 2)] 35 | public virtual bool Final { get; set; } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/a2a-net.Core/JsonRpcVersion.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A; 15 | 16 | /// 17 | /// Enumerates all supported versions of the JSON RPC specification 18 | /// 19 | public static class JsonRpcVersion 20 | { 21 | 22 | /// 23 | /// Indicates JSON RPC 2.0 24 | /// 25 | public const string V2 = "2.0"; 26 | 27 | /// 28 | /// Gets a new containing all supported values 29 | /// 30 | /// An containing all supported values 31 | public static IEnumerable AsEnumerable() 32 | { 33 | yield return V2; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/MessageRole.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A; 15 | 16 | /// 17 | /// Enumerates all possible message roles 18 | /// 19 | public static class MessageRole 20 | { 21 | 22 | /// 23 | /// Indicates an agent message 24 | /// 25 | public const string Agent = "agent"; 26 | /// 27 | /// Indicates a user message 28 | /// 29 | public const string User = "user"; 30 | 31 | /// 32 | /// Gets a new containing all supported values 33 | /// 34 | /// An containing all supported values 35 | public static IEnumerable AsEnumerable() 36 | { 37 | yield return Agent; 38 | yield return User; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/AgentAuthentication.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents the authentication requirements for an agent 18 | /// 19 | [DataContract] 20 | public record AgentAuthentication 21 | { 22 | 23 | /// 24 | /// Gets/sets the list of authentication schemes supported 25 | /// 26 | [Required, MinLength(1)] 27 | [DataMember(Name = "schemes", Order = 1), JsonPropertyName("schemes"), JsonPropertyOrder(1), YamlMember(Alias = "schemes", Order = 1)] 28 | public virtual EquatableList Schemes { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets the credentials, if any, used in conjunction with the specified authentication schemes 32 | /// 33 | [DataMember(Name = "credentials", Order = 2), JsonPropertyName("credentials"), JsonPropertyOrder(2), YamlMember(Alias = "credentials", Order = 2)] 34 | public virtual string? Credentials { get; set; } 35 | 36 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/AgentCapabilities.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents an object used to describe an agent's capabilities 18 | /// 19 | [DataContract] 20 | public record AgentCapabilities 21 | { 22 | 23 | /// 24 | /// Gets/sets a boolean indicating whether or not the agent supports streaming 25 | /// 26 | [DataMember(Name = "streaming", Order = 1), JsonPropertyName("streaming"), JsonPropertyOrder(1), YamlMember(Alias = "streaming", Order = 1)] 27 | public virtual bool Streaming { get; set; } 28 | 29 | /// 30 | /// Gets/sets a boolean indicating whether or not the agent can notify updates to client using push notifications 31 | /// 32 | [DataMember(Name = "pushNotifications", Order = 2), JsonPropertyName("pushNotifications"), JsonPropertyOrder(2), YamlMember(Alias = "pushNotifications", Order = 2)] 33 | public virtual bool PushNotifications { get; set; } 34 | 35 | /// 36 | /// Gets/sets a boolean indicating whether or not the agent exposes status change history for tasks 37 | /// 38 | [DataMember(Name = "stateTransitionHistory", Order = 3), JsonPropertyName("stateTransitionHistory"), JsonPropertyOrder(3), YamlMember(Alias = "stateTransitionHistory", Order = 3)] 39 | public virtual bool StateTransitionHistory { get; set; } 40 | 41 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/AgentProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents an object used to describe an agent's provider 18 | /// 19 | [DataContract] 20 | public record AgentProvider 21 | { 22 | 23 | /// 24 | /// Gets/sets the name of the organization that provides or maintains the agent 25 | /// 26 | [Required, MinLength(1)] 27 | [DataMember(Name = "organization", Order = 1), JsonPropertyName("organization"), JsonPropertyOrder(1), YamlMember(Alias = "organization", Order = 1)] 28 | public virtual string Organization { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets a url, if any, referencing the official website of the agent's organization or provider 32 | /// 33 | [DataMember(Name = "url", Order = 2), JsonPropertyName("url"), JsonPropertyOrder(2), YamlMember(Alias = "url", Order = 2)] 34 | public virtual Uri? Url { get; set; } 35 | 36 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/Artifact.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents a structured artifact 18 | /// 19 | [DataContract] 20 | public record Artifact 21 | { 22 | 23 | /// 24 | /// Gets/sets the artifact's name, if any 25 | /// 26 | [DataMember(Name = "name", Order = 1), JsonPropertyName("name"), JsonPropertyOrder(1), YamlMember(Alias = "name", Order = 1)] 27 | public virtual string? Name { get; set; } 28 | 29 | /// 30 | /// Gets/sets the artifact's description, if any 31 | /// 32 | [DataMember(Name = "description", Order = 2), JsonPropertyName("description"), JsonPropertyOrder(2), YamlMember(Alias = "description", Order = 2)] 33 | public virtual string? Description { get; set; } 34 | 35 | /// 36 | /// Gets/sets a list containing the artifact's parts, if any 37 | /// 38 | [DataMember(Name = "parts", Order = 3), JsonPropertyName("parts"), JsonPropertyOrder(3), YamlMember(Alias = "parts", Order = 3)] 39 | public virtual EquatableList? Parts { get; set; } 40 | 41 | /// 42 | /// Gets/sets the artifact's index 43 | /// 44 | [DataMember(Name = "index", Order = 4), JsonPropertyName("index"), JsonPropertyOrder(4), YamlMember(Alias = "index", Order = 4)] 45 | public virtual uint Index { get; set; } 46 | 47 | /// 48 | /// Gets/sets a boolean indicating whether or not the artifact should be appended to the existing content 49 | /// 50 | [DataMember(Name = "append", Order = 5), JsonPropertyName("append"), JsonPropertyOrder(5), YamlMember(Alias = "append", Order = 5)] 51 | public virtual bool? Append { get; set; } 52 | 53 | /// 54 | /// Gets/sets a boolean indicating whether or not the artifact is the last chunk in a sequence 55 | /// 56 | [DataMember(Name = "lastChunk", Order = 6), JsonPropertyName("lastChunk"), JsonPropertyOrder(6), YamlMember(Alias = "lastChunk", Order = 6)] 57 | public virtual bool? LastChunk { get; set; } 58 | 59 | /// 60 | /// Gets/sets a key/value mapping that contains the message's additional properties, if any 61 | /// 62 | [DataMember(Name = "metadata", Order = 7), JsonPropertyName("metadata"), JsonPropertyOrder(7), YamlMember(Alias = "metadata", Order = 7)] 63 | public virtual EquatableDictionary? Metadata { get; set; } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/AuthenticationInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents an object used to configure authentication 18 | /// 19 | [DataContract] 20 | public record AuthenticationInfo 21 | { 22 | 23 | /// 24 | /// Gets/sets the list of authentication schemes supported 25 | /// 26 | [Required, MinLength(1)] 27 | [DataMember(Name = "role", Order = 1), JsonPropertyName("role"), JsonPropertyOrder(1), YamlMember(Alias = "role", Order = 1)] 28 | public virtual EquatableList Schemes { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets the credentials, if any, used in conjunction with the specified authentication schemes 32 | /// 33 | [DataMember(Name = "credentials", Order = 2), JsonPropertyName("credentials"), JsonPropertyOrder(2), YamlMember(Alias = "credentials", Order = 2)] 34 | public virtual string? Credentials { get; set; } 35 | 36 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/DataPart.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents a data part 18 | /// 19 | [DataContract] 20 | public record DataPart 21 | : Part 22 | { 23 | 24 | /// 25 | [IgnoreDataMember, JsonIgnore, YamlIgnore] 26 | public override string Type => PartType.Data; 27 | 28 | /// 29 | /// Gets/sets the part's data 30 | /// 31 | [Required] 32 | [DataMember(Name = "data", Order = 1), JsonPropertyName("data"), JsonPropertyOrder(1), YamlMember(Alias = "data", Order = 1)] 33 | public virtual EquatableDictionary Data { get; set; } = null!; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/File.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents a file 18 | /// 19 | [DataContract] 20 | public record File 21 | { 22 | 23 | /// 24 | /// Gets/sets the file's name, if any 25 | /// 26 | [DataMember(Name = "name", Order = 1), JsonPropertyName("name"), JsonPropertyOrder(1), YamlMember(Alias = "name", Order = 1)] 27 | public virtual string? Name { get; set; } 28 | 29 | /// 30 | /// Gets/sets the file's MIME type, if any 31 | /// 32 | [DataMember(Name = "mimeType", Order = 2), JsonPropertyName("mimeType"), JsonPropertyOrder(2), YamlMember(Alias = "mimeType", Order = 2)] 33 | public virtual string? MimeType { get; set; } 34 | 35 | /// 36 | /// Gets/sets the file's base64 encoded content, if any 37 | /// 38 | [DataMember(Name = "bytes", Order = 3), JsonPropertyName("bytes"), JsonPropertyOrder(3), YamlMember(Alias = "bytes", Order = 3)] 39 | public virtual string? Bytes { get; set; } 40 | 41 | /// 42 | /// Gets/sets the file's uri, if any 43 | /// 44 | [DataMember(Name = "uri", Order = 4), JsonPropertyName("uri"), JsonPropertyOrder(4), YamlMember(Alias = "uri", Order = 4)] 45 | public virtual Uri? Uri { get; set; } 46 | 47 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/FilePart.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents a file part 18 | /// 19 | [DataContract] 20 | public record FilePart 21 | : Part 22 | { 23 | 24 | /// 25 | [IgnoreDataMember, JsonIgnore, YamlIgnore] 26 | public override string Type => PartType.File; 27 | 28 | /// 29 | /// Gets/sets the part's text 30 | /// 31 | [Required] 32 | [DataMember(Name = "file", Order = 1), JsonPropertyName("file"), JsonPropertyOrder(1), YamlMember(Alias = "file", Order = 1)] 33 | public virtual File File { get; set; } = null!; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/Message.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents a message 18 | /// 19 | [DataContract] 20 | public record Message 21 | { 22 | 23 | /// 24 | /// Gets/sets the message's role 25 | /// 26 | [Required, AllowedValues(MessageRole.Agent, MessageRole.User)] 27 | [DataMember(Name = "role", Order = 1), JsonPropertyName("role"), JsonPropertyOrder(1), YamlMember(Alias = "role", Order = 1)] 28 | public virtual string Role { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets a list containing the message's parts, if any 32 | /// 33 | [DataMember(Name = "parts", Order = 2), JsonPropertyName("parts"), JsonPropertyOrder(2), YamlMember(Alias = "parts", Order = 2)] 34 | public virtual EquatableList? Parts { get; set; } 35 | 36 | /// 37 | /// Gets/sets a key/value mapping that contains the message's additional properties, if any 38 | /// 39 | [DataMember(Name = "metadata", Order = 3), JsonPropertyName("metadata"), JsonPropertyOrder(3), YamlMember(Alias = "metadata", Order = 3)] 40 | public virtual EquatableDictionary? Metadata { get; set; } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/Part.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents a fully formed piece of content exchanged between a client and a remote agent as part of a message or an artifact 18 | /// 19 | [DataContract] 20 | [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] 21 | [JsonDerivedType(typeof(DataPart), PartType.Data)] 22 | [JsonDerivedType(typeof(FilePart), PartType.File)] 23 | [JsonDerivedType(typeof(TextPart), PartType.Text)] 24 | public abstract record Part 25 | { 26 | 27 | /// 28 | /// Gets the part's type 29 | /// 30 | public abstract string Type { get; } 31 | 32 | /// 33 | /// Gets/sets a key/value mapping that contains the message's additional properties, if any 34 | /// 35 | [DataMember(Name = "metadata", Order = 99), JsonPropertyName("metadata"), JsonPropertyOrder(99), YamlMember(Alias = "metadata", Order = 99)] 36 | public virtual EquatableDictionary? Metadata { get; set; } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/PushNotificationConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents an object used to configure push notifications 18 | /// 19 | [DataContract] 20 | public record PushNotificationConfiguration 21 | { 22 | 23 | /// 24 | /// Gets/sets the endpoint URL to which the push notification should be sent 25 | /// 26 | [Required] 27 | [DataMember(Name = "url", Order = 1), JsonPropertyName("url"), JsonPropertyOrder(1), YamlMember(Alias = "url", Order = 1)] 28 | public virtual Uri Url { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets a token;, if any, that uniquely identifies the task or session associated with the push notification 32 | /// 33 | [DataMember(Name = "token", Order = 2), JsonPropertyName("token"), JsonPropertyOrder(2), YamlMember(Alias = "token", Order = 2)] 34 | public virtual string? Token { get; set; } 35 | 36 | /// 37 | /// Gets/sets information, if any, about the authentication used to push notification to the configured endpoint 38 | /// 39 | [DataMember(Name = "authentication", Order = 3), JsonPropertyName("authentication"), JsonPropertyOrder(3), YamlMember(Alias = "authentication", Order = 3)] 40 | public virtual AuthenticationInfo? Authentication { get; set; } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/RpcError.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents an object used to describe an error that has occurred during an RPC call 18 | /// 19 | [DataContract] 20 | public record RpcError 21 | { 22 | 23 | /// 24 | /// Initializes a new 25 | /// 26 | public RpcError() { } 27 | 28 | /// 29 | /// Initializes a new 30 | /// 31 | /// The error code 32 | /// The error message 33 | /// Data, if any, associated to the error 34 | public RpcError(int code, string message, object? data = null) 35 | { 36 | ArgumentException.ThrowIfNullOrWhiteSpace(message); 37 | Code = code; 38 | Message = message; 39 | Data = data; 40 | } 41 | 42 | /// 43 | /// Gets/sets the error code 44 | /// 45 | [DataMember(Name = "code", Order = 1), JsonPropertyName("code"), JsonPropertyOrder(1), YamlMember(Alias = "code", Order = 1)] 46 | public virtual int Code { get; set; } 47 | 48 | /// 49 | /// Gets/sets the error message 50 | /// 51 | [Required, MinLength(1)] 52 | [DataMember(Name = "message", Order = 2), JsonPropertyName("message"), JsonPropertyOrder(2), YamlMember(Alias = "message", Order = 2)] 53 | public virtual string Message { get; set; } = null!; 54 | 55 | /// 56 | /// Gets/sets data, if any, associated to the error 57 | /// 58 | [DataMember(Name = "data", Order = 3), JsonPropertyName("data"), JsonPropertyOrder(3), YamlMember(Alias = "data", Order = 3)] 59 | public virtual object? Data { get; set; } 60 | 61 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/Task.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents a task 18 | /// 19 | [DataContract] 20 | public record Task 21 | { 22 | 23 | /// 24 | /// Gets/sets the task's unique identifier 25 | /// 26 | [Required, MinLength(1)] 27 | [DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)] 28 | public virtual string Id { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets the unique identifier of the session holding the task 32 | /// 33 | [Required, MinLength(1)] 34 | [DataMember(Name = "sessionId", Order = 2), JsonPropertyName("sessionId"), JsonPropertyOrder(2), YamlMember(Alias = "sessionId", Order = 2)] 35 | public virtual string SessionId { get; set; } = null!; 36 | 37 | /// 38 | /// Gets/sets the task's status 39 | /// 40 | [Required] 41 | [DataMember(Name = "status", Order = 3), JsonPropertyName("status"), JsonPropertyOrder(3), YamlMember(Alias = "status", Order = 3)] 42 | public virtual TaskStatus Status { get; set; } = null!; 43 | 44 | /// 45 | /// Gets/sets the history of all the task's messages 46 | /// 47 | [DataMember(Name = "history", Order = 4), JsonPropertyName("history"), JsonPropertyOrder(4), YamlMember(Alias = "history", Order = 4)] 48 | public virtual EquatableList? History { get; set; } 49 | 50 | /// 51 | /// Gets/sets a collection of the artifacts, if any, created by the agent 52 | /// 53 | [DataMember(Name = "artifacts", Order = 5), JsonPropertyName("artifacts"), JsonPropertyOrder(5), YamlMember(Alias = "artifacts", Order = 5)] 54 | public virtual EquatableList? Artifacts { get; set; } 55 | 56 | /// 57 | /// Gets/sets a key/value mapping that contains the task's additional properties, if any 58 | /// 59 | [DataMember(Name = "metadata", Order = 99), JsonPropertyName("metadata"), JsonPropertyOrder(99), YamlMember(Alias = "metadata", Order = 99)] 60 | public virtual EquatableDictionary? Metadata { get; set; } 61 | 62 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/TaskIdParameters.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents the parameters of a task query 18 | /// 19 | [DataContract] 20 | public record TaskIdParameters 21 | { 22 | 23 | /// 24 | /// Initializes a new 25 | /// 26 | public TaskIdParameters() { } 27 | 28 | /// 29 | /// Initializes a new 30 | /// 31 | /// The task's id 32 | /// A key/value mapping that contains the task's additional properties, if any 33 | public TaskIdParameters(string id, IDictionary? metadata = null) 34 | { 35 | ArgumentException.ThrowIfNullOrWhiteSpace(id); 36 | Id = id; 37 | Metadata = metadata == null ? null : new(metadata); 38 | } 39 | 40 | /// 41 | /// Gets/sets the task's id 42 | /// 43 | [Required, MinLength(1)] 44 | [DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)] 45 | public virtual string Id { get; set; } = null!; 46 | 47 | /// 48 | /// Gets/sets a key/value mapping that contains the task's additional properties, if any 49 | /// 50 | [DataMember(Name = "metadata", Order = 2), JsonPropertyName("metadata"), JsonPropertyOrder(2), YamlMember(Alias = "metadata", Order = 2)] 51 | public virtual EquatableDictionary? Metadata { get; set; } 52 | 53 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/TaskPushNotificationConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents an object used to configure task-related push notifications 18 | /// 19 | [DataContract] 20 | public record TaskPushNotificationConfiguration 21 | { 22 | 23 | /// 24 | /// Gets/sets the id of the task to push notifications about 25 | /// 26 | [Required, MinLength(1)] 27 | [DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)] 28 | public virtual string Id { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets an object used to configure task-related push notifications 32 | /// 33 | [DataMember(Name = "pushNotificationConfig", Order = 2), JsonPropertyName("pushNotificationConfig"), JsonPropertyOrder(2), YamlMember(Alias = "pushNotificationConfig", Order = 2)] 34 | public virtual PushNotificationConfiguration? PushNotificationConfig { get; set; } 35 | 36 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/TaskQueryParameters.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents the parameters of a task query 18 | /// 19 | [DataContract] 20 | public record TaskQueryParameters 21 | { 22 | 23 | /// 24 | /// Gets/sets the id of the task to query 25 | /// 26 | [Required, MinLength(1)] 27 | [DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)] 28 | public virtual string Id { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets the length, if any, of the task message history to get 32 | /// 33 | [DataMember(Name = "historyLength", Order = 2), JsonPropertyName("historyLength"), JsonPropertyOrder(2), YamlMember(Alias = "historyLength", Order = 2)] 34 | public virtual uint? HistoryLength { get; set; } = null!; 35 | 36 | /// 37 | /// Gets/sets a key/value mapping that contains the task's additional properties, if any 38 | /// 39 | [DataMember(Name = "metadata", Order = 3), JsonPropertyName("metadata"), JsonPropertyOrder(3), YamlMember(Alias = "metadata", Order = 3)] 40 | public virtual EquatableDictionary? Metadata { get; set; } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/TaskSendParameters.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents the parameters used to send a task 18 | /// 19 | [DataContract] 20 | public record TaskSendParameters 21 | { 22 | 23 | /// 24 | /// Gets/sets the task's unique identifier 25 | /// 26 | [Required, MinLength(1)] 27 | [DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)] 28 | public virtual string Id { get; set; } = Guid.NewGuid().ToString("N"); 29 | 30 | /// 31 | /// Gets/sets the unique identifier of the session the task belongs to 32 | /// The server creates a new session id for new tasks if not set 33 | /// 34 | [DataMember(Name = "sessionId", Order = 2), JsonPropertyName("sessionId"), JsonPropertyOrder(2), YamlMember(Alias = "sessionId", Order = 2)] 35 | public virtual string? SessionId { get; set; } 36 | 37 | /// 38 | /// Gets/sets the task's message 39 | /// 40 | [Required] 41 | [DataMember(Name = "message", Order = 3), JsonPropertyName("message"), JsonPropertyOrder(3), YamlMember(Alias = "message", Order = 3)] 42 | public virtual Message Message { get; set; } = null!; 43 | 44 | /// 45 | /// Gets/sets the number of recent messages, if any, to be retrieved 46 | /// 47 | [Required] 48 | [DataMember(Name = "historyLength", Order = 4), JsonPropertyName("historyLength"), JsonPropertyOrder(4), YamlMember(Alias = "historyLength", Order = 4)] 49 | public virtual uint? HistoryLength { get; set; } = null!; 50 | 51 | /// 52 | /// Gets/sets the configuration, if any, for the task's push notifications 53 | /// 54 | [DataMember(Name = "pushNotification", Order = 5), JsonPropertyName("pushNotification"), JsonPropertyOrder(5), YamlMember(Alias = "pushNotification", Order = 5)] 55 | public virtual PushNotificationConfiguration? PushNotification { get; set; } 56 | 57 | /// 58 | /// Gets/sets a key/value mapping that contains the request's additional properties, if any 59 | /// 60 | [DataMember(Name = "metadata", Order = 99), JsonPropertyName("metadata"), JsonPropertyOrder(99), YamlMember(Alias = "metadata", Order = 99)] 61 | public virtual EquatableDictionary? Metadata { get; set; } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/TaskStatus.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents an object used to describe the status of a task 18 | /// 19 | [DataContract] 20 | public record TaskStatus 21 | { 22 | 23 | /// 24 | /// Gets/sets the task's state 25 | /// 26 | [Required, AllowedValues(TaskState.Submitted, TaskState.Working, TaskState.InputRequired, TaskState.Completed, TaskState.Cancelled, TaskState.Failed, TaskState.Unknown)] 27 | [DataMember(Name = "state", Order = 1), JsonPropertyName("state"), JsonPropertyOrder(1), YamlMember(Alias = "state", Order = 1)] 28 | public virtual string State { get; set; } = null!; 29 | 30 | /// 31 | /// Gets/sets additional status updates, if any, for the client 32 | /// 33 | [DataMember(Name = "message", Order = 2), JsonPropertyName("message"), JsonPropertyOrder(2), YamlMember(Alias = "message", Order = 2)] 34 | public virtual Message? Message { get; set; } 35 | 36 | /// 37 | /// Gets/sets the task's timestamp 38 | /// 39 | [DataMember(Name = "timestamp", Order = 3), JsonPropertyName("timestamp"), JsonPropertyOrder(3), YamlMember(Alias = "timestamp", Order = 3)] 40 | public virtual DateTimeOffset Timestamp { get; set; } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Models/TextPart.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Models; 15 | 16 | /// 17 | /// Represents a text part 18 | /// 19 | [DataContract] 20 | public record TextPart 21 | : Part 22 | { 23 | 24 | /// 25 | /// Initializes a new 26 | /// 27 | public TextPart() { } 28 | 29 | /// 30 | /// Initializes a new 31 | /// 32 | /// The part's text 33 | public TextPart(string text) 34 | { 35 | ArgumentException.ThrowIfNullOrWhiteSpace(text); 36 | Text = text; 37 | } 38 | 39 | /// 40 | [IgnoreDataMember, JsonIgnore, YamlIgnore] 41 | public override string Type => PartType.Text; 42 | 43 | /// 44 | /// Gets/sets the part's text 45 | /// 46 | [Required] 47 | [DataMember(Name = "text", Order = 1), JsonPropertyName("text"), JsonPropertyOrder(1), YamlMember(Alias = "text", Order = 1)] 48 | public virtual string Text { get; set; } = null!; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/a2a-net.Core/PartType.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A; 15 | 16 | /// 17 | /// Enumerates all types of parts 18 | /// 19 | public static class PartType 20 | { 21 | 22 | /// 23 | /// Indicates a data part 24 | /// 25 | public const string Data = "data"; 26 | /// 27 | /// Indicates a file part 28 | /// 29 | public const string File = "file"; 30 | /// 31 | /// Indicates a text part 32 | /// 33 | public const string Text = "text"; 34 | 35 | /// 36 | /// Gets a new containing all supported values 37 | /// 38 | /// An containing all supported values 39 | public static IEnumerable AsEnumerable() 40 | { 41 | yield return Data; 42 | yield return File; 43 | yield return Text; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Requests/CancelTaskRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Requests; 15 | 16 | /// 17 | /// Represents the request used to cancel a previously submitted task 18 | /// 19 | [DataContract] 20 | public record CancelTaskRequest 21 | : RpcRequest 22 | { 23 | 24 | /// 25 | /// Initializes a new 26 | /// 27 | public CancelTaskRequest() : base("tasks/cancel") { } 28 | 29 | /// 30 | /// Initializes a new 31 | /// 32 | /// The request's parameters 33 | public CancelTaskRequest(TaskIdParameters @params) 34 | : this() 35 | { 36 | ArgumentNullException.ThrowIfNull(@params); 37 | Params = @params; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Requests/GetTaskPushNotificationsRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Requests; 15 | 16 | /// 17 | /// Represents the request used to retrieve the currently configured push notification configuration for a Task 18 | /// 19 | [DataContract] 20 | public record GetTaskPushNotificationsRequest() 21 | : RpcRequest("tasks/pushNotification/get") 22 | { 23 | 24 | 25 | 26 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Requests/GetTaskRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Requests; 15 | 16 | /// 17 | /// Represents the request used to retrieve the generated Artifacts for a Task 18 | /// 19 | [DataContract] 20 | public record GetTaskRequest() 21 | : RpcRequest("tasks/get") 22 | { 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Requests/SendTaskRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Requests; 15 | 16 | /// 17 | /// Represents the request used to create, continue or restart a task 18 | /// 19 | [DataContract] 20 | public record SendTaskRequest() 21 | : RpcRequest("tasks/send") 22 | { 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Requests/SendTaskStreamingRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Requests; 15 | 16 | /// 17 | /// Represents the request used to create a Task and to stream its updates 18 | /// 19 | [DataContract] 20 | public record SendTaskStreamingRequest() 21 | : RpcRequest("tasks/sendSubscribe") 22 | { 23 | 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Requests/SetTaskPushNotificationsRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Requests; 15 | 16 | /// 17 | /// Represents the request used to configure a push notification URL for receiving an update on Task status change 18 | /// 19 | [DataContract] 20 | public record SetTaskPushNotificationsRequest() 21 | : RpcRequest("tasks/pushNotification/set") 22 | { 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Requests/TaskResubscriptionRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Requests; 15 | 16 | /// 17 | /// Represents the request used to resubscribe to a remote agent 18 | /// 19 | [DataContract] 20 | public record TaskResubscriptionRequest() 21 | : RpcRequest("tasks/resubscribe") 22 | { 23 | 24 | 25 | 26 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/RpcEvent.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A; 15 | 16 | /// 17 | /// Represents the base class for all A2A events 18 | /// 19 | [DataContract] 20 | public abstract record RpcEvent 21 | { 22 | 23 | /// 24 | /// Gets/sets a key/value mapping that contains the event's additional properties, if any 25 | /// 26 | [DataMember(Name = "metadata", Order = 99), JsonPropertyName("metadata"), JsonPropertyOrder(99), YamlMember(Alias = "metadata", Order = 99)] 27 | public virtual EquatableDictionary? Metadata { get; set; } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/a2a-net.Core/RpcMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A; 15 | 16 | /// 17 | /// Represents the base class for all A2A RPC messages 18 | /// 19 | public abstract record RpcMessage 20 | { 21 | 22 | /// 23 | /// Gets/sets the JSON RPC version to use 24 | /// 25 | [Required, AllowedValues(JsonRpcVersion.V2), DefaultValue(JsonRpcVersion.V2)] 26 | [DataMember(Name = "jsonrpc", Order = 0), JsonPropertyName("jsonrpc"), JsonPropertyOrder(0), YamlMember(Alias = "jsonrpc", Order = 0)] 27 | public virtual string JsonRpc { get; set; } = JsonRpcVersion.V2; 28 | 29 | /// 30 | /// Gets/sets the message's unique identifier 31 | /// 32 | [Required, MinLength(1)] 33 | [DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)] 34 | public virtual string Id { get; set; } = null!; 35 | 36 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/RpcRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A; 15 | 16 | /// 17 | /// Represents the base class for all A2A RPC requests 18 | /// 19 | [DataContract] 20 | public record RpcRequest 21 | : RpcMessage 22 | { 23 | 24 | /// 25 | /// Initializes a new 26 | /// 27 | public RpcRequest() 28 | { 29 | Id = Guid.NewGuid().ToString("N"); 30 | } 31 | 32 | /// 33 | /// Initializes a new 34 | /// 35 | /// The name of the RPC method to invoke 36 | public RpcRequest(string method) 37 | { 38 | ArgumentException.ThrowIfNullOrWhiteSpace(method); 39 | Method = method; 40 | } 41 | 42 | /// 43 | /// Gets/sets the name of the RPC method to invoke 44 | /// 45 | [Required, MinLength(1)] 46 | [DataMember(Name = "method", Order = 2), JsonInclude, JsonPropertyName("method"), JsonPropertyOrder(2), YamlMember(Alias = "method", Order = 2)] 47 | public virtual string Method { get; set; } = null!; 48 | 49 | /// 50 | /// Gets/sets a key/value mapping, if any, containing extension properties 51 | /// 52 | [JsonExtensionData] 53 | public virtual IDictionary? ExtensionData { get; set; } 54 | 55 | } 56 | 57 | /// 58 | /// Represents the base class for all A2A RPC requests 59 | /// 60 | /// The type of the request's parameters 61 | [DataContract] 62 | public record RpcRequest 63 | : RpcRequest 64 | where TParams : class 65 | { 66 | 67 | /// 68 | /// Initializes a new 69 | /// 70 | public RpcRequest() : base() { } 71 | 72 | /// 73 | /// Initializes a new 74 | /// 75 | /// The name of the RPC method to invoke 76 | public RpcRequest(string method): base(method) { } 77 | 78 | /// 79 | /// Gets/sets the request's parameters 80 | /// 81 | [Required] 82 | [DataMember(Name = "params", Order = 3), JsonInclude, JsonPropertyName("params"), JsonPropertyOrder(3), YamlMember(Alias = "params", Order = 3)] 83 | public virtual TParams Params { get; set; } = null!; 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/a2a-net.Core/RpcResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A; 15 | 16 | /// 17 | /// Represents the base class for all A2A responses 18 | /// 19 | [DataContract] 20 | public abstract record RpcResponse 21 | : RpcMessage 22 | { 23 | 24 | /// 25 | /// Gets/sets the error, if any, that has occurred during the request's execution 26 | /// 27 | [DataMember(Name = "error", Order = 2), JsonPropertyName("error"), JsonPropertyOrder(2), YamlMember(Alias = "error", Order = 2)] 28 | public virtual RpcError? Error { get; set; } = null!; 29 | 30 | } 31 | 32 | /// 33 | /// Represents the base class for all A2A responses 34 | /// 35 | /// The type of the response's content 36 | [DataContract] 37 | public record RpcResponse 38 | : RpcResponse 39 | where TResult : class 40 | { 41 | 42 | /// 43 | /// Gets/sets the response's content 44 | /// 45 | [Required] 46 | [DataMember(Name = "result", Order = 2), JsonInclude, JsonPropertyName("result"), JsonPropertyOrder(2), YamlMember(Alias = "result", Order = 2)] 47 | public virtual TResult? Result { get; set; } = null!; 48 | 49 | } -------------------------------------------------------------------------------- /src/a2a-net.Core/Serialization/Json/TaskEventJsonConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Serialization.Json; 15 | 16 | /// 17 | /// Represents the used to serialize/deserialize s 18 | /// 19 | public class TaskEventJsonConverter 20 | : JsonConverter 21 | { 22 | 23 | /// 24 | public override TaskEvent? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 25 | { 26 | using var doc = JsonDocument.ParseValue(ref reader); 27 | var root = doc.RootElement; 28 | if (root.TryGetProperty("status", out _)) return JsonSerializer.Deserialize(root.GetRawText(), options); 29 | if (root.TryGetProperty("artifact", out _)) return JsonSerializer.Deserialize(root.GetRawText(), options); 30 | throw new JsonException("Unable to determine event type: no known discriminator property found."); 31 | } 32 | 33 | /// 34 | public override void Write(Utf8JsonWriter writer, TaskEvent value, JsonSerializerOptions options) => JsonSerializer.Serialize(writer, value, value.GetType(), options); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/a2a-net.Core/TaskState.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A; 15 | 16 | /// 17 | /// Enumerates all possible task states 18 | /// 19 | public static class TaskState 20 | { 21 | 22 | /// 23 | /// Indicates that the task has been submitted and is pending executing 24 | /// 25 | public const string Submitted = "submitted"; 26 | /// 27 | /// Indicates that the task is being executed 28 | /// 29 | public const string Working = "working"; 30 | /// 31 | /// Indicates that the task requires input 32 | /// 33 | public const string InputRequired = "input-required"; 34 | /// 35 | /// Indicates that the task ran to completion 36 | /// 37 | public const string Completed = "completed"; 38 | /// 39 | /// Indicates that the task has been cancelled 40 | /// 41 | public const string Cancelled = "cancelled"; 42 | /// 43 | /// Indicates that the task has failed 44 | /// 45 | public const string Failed = "failed"; 46 | /// 47 | /// Indicates that the task is an unknown status 48 | /// 49 | public const string Unknown = "unknown"; 50 | 51 | /// 52 | /// Gets a new containing all supported values 53 | /// 54 | /// An containing all supported values 55 | public static IEnumerable AsEnumerable() 56 | { 57 | yield return Submitted; 58 | yield return Working; 59 | yield return InputRequired; 60 | yield return Completed; 61 | yield return Cancelled; 62 | yield return Failed; 63 | yield return Unknown; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/a2a-net.Core/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Events; 15 | global using A2A.Models; 16 | global using A2A.Requests; 17 | global using A2A.Serialization.Json; 18 | global using Neuroglia; 19 | global using StreamJsonRpc; 20 | global using System.ComponentModel; 21 | global using System.ComponentModel.DataAnnotations; 22 | global using System.Net.Mime; 23 | global using System.Runtime.Serialization; 24 | global using System.Text.Json; 25 | global using System.Text.Json.Serialization; 26 | global using YamlDotNet.Serialization; 27 | -------------------------------------------------------------------------------- /src/a2a-net.Core/a2a-net.Core.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.Client 8 | 0.8.0 9 | $(VersionPrefix) 10 | $(VersionPrefix) 11 | en 12 | true 13 | True 14 | true 15 | A2A-NET Protocol Client 16 | Contains the A2A Protocol client 17 | a2a;client 18 | true 19 | Apache-2.0 20 | README.md 21 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 22 | https://github.com/neuroglia-io/a2a 23 | https://github.com/neuroglia-io/a2a 24 | git 25 | embedded 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/a2a-net.Server.AspNetCore/Extensions/IApplicationBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.AspNetCore; 15 | 16 | /// 17 | /// Defines extensions for s 18 | /// 19 | public static class IApplicationBuilderExtensions 20 | { 21 | 22 | /// 23 | /// Maps a well-known HTTP endpoint for A2A agent discovery, exposing the agent manifest(s) as JSON 24 | /// If a single is registered, it will be served at /.well-known/agent.json 25 | /// If multiple agents are registered, they will be served as a list at /.well-known/agents.json 26 | /// 27 | /// The to configure 28 | public static void MapA2AWellKnownAgentEndpoint(this IApplicationBuilder app) 29 | { 30 | var agents = app.ApplicationServices.GetServices().ToList(); 31 | if (agents.Count < 1) return; 32 | else if(agents.Count == 1) 33 | { 34 | app.Map("/.well-known/agent.json", app => 35 | { 36 | app.Use(async (HttpContext context, RequestDelegate next) => 37 | { 38 | context.Response.ContentType = MediaTypeNames.Application.Json; 39 | await context.Response.WriteAsJsonAsync(agents[0], context.RequestServices.GetRequiredService>().Value.JsonSerializerOptions, context.RequestAborted); 40 | }); 41 | }); 42 | } 43 | else 44 | { 45 | app.Map("/.well-known/agents.json", app => 46 | { 47 | app.Use(async (HttpContext context, RequestDelegate next) => 48 | { 49 | context.Response.ContentType = MediaTypeNames.Application.Json; 50 | await context.Response.WriteAsJsonAsync(agents, context.RequestServices.GetRequiredService>().Value.JsonSerializerOptions, context.RequestAborted); 51 | }); 52 | }); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/a2a-net.Server.AspNetCore/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "A2A.Server.AspNetCore": { 4 | "commandName": "Project", 5 | "launchBrowser": true, 6 | "environmentVariables": { 7 | "ASPNETCORE_ENVIRONMENT": "Development" 8 | }, 9 | "applicationUrl": "https://localhost:51801;http://localhost:51802" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/a2a-net.Server.AspNetCore/Services/A2AWebSocketMiddleware.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using Microsoft.VisualStudio.Threading; 15 | 16 | namespace A2A.Server.AspNetCore.Services; 17 | 18 | /// 19 | /// Represents the middleware that handles WebSocket-based JSON-RPC requests for an A2A agent 20 | /// 21 | /// 22 | /// Initializes a new 23 | /// 24 | /// The service used to provide s 25 | public class A2AWebSocketMiddleware(IA2AProtocolServerProvider serverProvider) 26 | { 27 | 28 | readonly IA2AProtocolServerProvider _serverProvider = serverProvider; 29 | 30 | /// 31 | /// Invokes the 32 | /// 33 | /// The current 34 | /// A new awaitable 35 | public async System.Threading.Tasks.Task InvokeAsync(HttpContext context) 36 | { 37 | if (!context.WebSockets.IsWebSocketRequest) 38 | { 39 | context.Response.StatusCode = StatusCodes.Status405MethodNotAllowed; 40 | return; 41 | } 42 | var serverName = context.Request.RouteValues.TryGetValue(A2AEndpointRouteBuilderExtensions.AgentVariableName, out var value) && value is string name && !string.IsNullOrWhiteSpace(name) ? name : A2AProtocolServer.DefaultName; 43 | var server = _serverProvider.Get(serverName); 44 | using var socket = await context.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false); 45 | using var jsonRpc = new JsonRpc(new WebSocketMessageHandler(socket, new SystemTextJsonFormatter()), server); 46 | jsonRpc.CancelLocallyInvokedMethodsWhenConnectionIsClosed = true; 47 | jsonRpc.StartListening(); 48 | await jsonRpc.Completion.WithCancellation(context.RequestAborted).ConfigureAwait(false); 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /src/a2a-net.Server.AspNetCore/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Errors; 15 | global using A2A.Events; 16 | global using A2A.Models; 17 | global using A2A.Requests; 18 | global using A2A.Server.Infrastructure.Services; 19 | global using Microsoft.AspNetCore.Http.Json; 20 | global using Microsoft.Extensions.Options; 21 | global using StreamJsonRpc; 22 | global using System.Net; 23 | global using System.Net.Mime; 24 | global using System.Text; 25 | global using System.Text.Json; 26 | -------------------------------------------------------------------------------- /src/a2a-net.Server.AspNetCore/a2a-net.Server.AspNetCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | Library 8 | A2A.Server.AspNetCore 9 | 0.8.0 10 | $(VersionPrefix) 11 | $(VersionPrefix) 12 | en 13 | true 14 | True 15 | true 16 | A2A-NET Protocol Server - ASP.NET Core 17 | Contains extensions and service used to host an A2A Protocol server in an ASP.NET Core application 18 | a2a;server;asp-net 19 | true 20 | Apache-2.0 21 | README.md 22 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 23 | https://github.com/neuroglia-io/a2a 24 | https://github.com/neuroglia-io/a2a 25 | git 26 | embedded 27 | 28 | 29 | 30 | 31 | True 32 | \ 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/AgentResponseContent.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure; 15 | 16 | /// 17 | /// Represents content returned by an agent as part of its response to a task's execution 18 | /// 19 | [DataContract] 20 | public record AgentResponseContent 21 | { 22 | 23 | /// 24 | /// Initializes a new 25 | /// 26 | [JsonConstructor] 27 | protected AgentResponseContent() { } 28 | 29 | /// 30 | /// Initializes a new 31 | /// 32 | /// The artifact produced by the agent 33 | public AgentResponseContent(Artifact artifact) 34 | { 35 | ArgumentNullException.ThrowIfNull(artifact); 36 | Artifact = artifact; 37 | } 38 | 39 | /// 40 | /// Initializes a new 41 | /// 42 | /// The message produced by the agent 43 | public AgentResponseContent(Message message) 44 | { 45 | ArgumentNullException.ThrowIfNull(message); 46 | Message = message; 47 | } 48 | 49 | /// 50 | /// Gets the type of the response content, indicating whether it is an artifact or a message 51 | /// 52 | [IgnoreDataMember, JsonIgnore, YamlIgnore] 53 | public virtual string Type => Artifact != null ? AgentResponseContentType.Artifact : AgentResponseContentType.Message; 54 | 55 | /// 56 | /// Gets the artifact produced by the agent, if any 57 | /// 58 | [DataMember(Name = "notifications", Order = 1), JsonInclude, JsonPropertyName("notifications"), JsonPropertyOrder(1), YamlMember(Alias = "notifications", Order = 1)] 59 | public virtual Artifact? Artifact { get; protected set; } 60 | 61 | /// 62 | /// Gets the message produced by the agent, if any 63 | /// 64 | [DataMember(Name = "message", Order = 1), JsonInclude, JsonPropertyName("message"), JsonPropertyOrder(1), YamlMember(Alias = "message", Order = 1)] 65 | public virtual Message? Message { get; protected set; } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/AgentResponseContentType.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure; 15 | 16 | /// 17 | /// Enumerates all supported types of contents returned by an agent as part of its response to a task's execution 18 | /// 19 | public static class AgentResponseContentType 20 | { 21 | 22 | /// 23 | /// Indicates an artifact content 24 | /// 25 | public const string Artifact = "artifact"; 26 | /// 27 | /// Indicates a message content 28 | /// 29 | public const string Message = "message"; 30 | 31 | /// 32 | /// Gets a new containing all supported values 33 | /// 34 | /// An containing all supported values 35 | public static IEnumerable AsEnumerable() 36 | { 37 | yield return Artifact; 38 | yield return Message; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/IA2AProtocolServer.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Defines the fundamentals of an server 18 | /// 19 | public interface IA2AProtocolServer 20 | : IA2AProtocolService 21 | { 22 | 23 | /// 24 | /// Gets the server's name 25 | /// 26 | string Name { get; } 27 | 28 | /// 29 | /// Gets an object that describes the A2A server's capabilities 30 | /// 31 | AgentCapabilities Capabilities { get; } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/IA2AProtocolServerProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Defines the fundamentals of a service used to provide s 18 | /// 19 | public interface IA2AProtocolServerProvider 20 | { 21 | 22 | /// 23 | /// Gets the with the specified name 24 | /// 25 | /// The name of the to get 26 | /// The with the specified name 27 | IA2AProtocolServer? Get(string name); 28 | 29 | } -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/IAgentProviderBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Defines the fundamentals of a service used to build the manifest of an agent's provider 18 | /// 19 | public interface IAgentProviderBuilder 20 | { 21 | 22 | /// 23 | /// Configures the agent's provider name 24 | /// 25 | /// The agent's provider name 26 | /// The configured 27 | IAgentProviderBuilder WithOrganization(string name); 28 | 29 | /// 30 | /// Configures the url referencing the official website of the agent's provider 31 | /// 32 | /// The url referencing the official website of the agent's provider 33 | /// The configured 34 | IAgentProviderBuilder WithUrl(Uri url); 35 | 36 | /// 37 | /// Builds the configured 38 | /// 39 | /// A new 40 | AgentProvider Build(); 41 | 42 | } -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/IAgentRuntime.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Defines the fundamentals of a service used to interact with an AI agent to execute tasks 18 | /// 19 | public interface IAgentRuntime 20 | { 21 | 22 | /// 23 | /// Executes the specified task and streams the content produced by the agent 24 | /// 25 | /// The task to execute 26 | /// A 27 | /// A new used to stream the content produced by the agent during the task's execution 28 | IAsyncEnumerable ExecuteAsync(TaskRecord task, CancellationToken cancellationToken = default); 29 | 30 | /// 31 | /// Cancels the specified task's execution 32 | /// 33 | /// The id of the task to cancel. 34 | /// A 35 | /// A new awaitable 36 | System.Threading.Tasks.Task CancelAsync(string taskId, CancellationToken cancellationToken = default); 37 | 38 | } -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/IAgentSkillBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Defines the fundamentals of a service used to build an agent's skill 18 | /// 19 | public interface IAgentSkillBuilder 20 | { 21 | 22 | /// 23 | /// Configures the skill's unique identifier 24 | /// 25 | /// The skill's unique identifier 26 | /// The configured 27 | IAgentSkillBuilder WithId(string id); 28 | 29 | /// 30 | /// Configures the skill's name 31 | /// 32 | /// The skill's name 33 | /// The configured 34 | IAgentSkillBuilder WithName(string name); 35 | 36 | /// 37 | /// Configures the skill's description 38 | /// 39 | /// The skill's description 40 | /// The configured 41 | IAgentSkillBuilder WithDescription(string description); 42 | 43 | /// 44 | /// Adds the specified tag to the skill to configure 45 | /// 46 | /// The tag to add 47 | /// The configured 48 | IAgentSkillBuilder WithTag(string tag); 49 | 50 | /// 51 | /// Adds a new example scenarios that the skill can perform 52 | /// 53 | /// The example to add 54 | /// The configured 55 | IAgentSkillBuilder WithExample(string example); 56 | 57 | /// 58 | /// Configures the skill to support the specified MIME type as input 59 | /// 60 | /// The MIME type to support 61 | /// The configured 62 | IAgentSkillBuilder WithInputMode(string contentType); 63 | 64 | /// 65 | /// Configures the skill to support the specified MIME type as output 66 | /// 67 | /// The MIME type to support 68 | /// The configured 69 | IAgentSkillBuilder WithOutputMode(string contentType); 70 | 71 | /// 72 | /// Builds the configured 73 | /// 74 | /// A new 75 | AgentSkill Build(); 76 | 77 | } -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/IJsonWebKeySet.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using Microsoft.IdentityModel.Tokens; 15 | 16 | namespace A2A.Server.Infrastructure.Services; 17 | 18 | /// 19 | /// Defines the fundamentals of a service used to manage the application's JSON Web Key Set (JWKS) 20 | /// 21 | public interface IJsonWebKeySet 22 | { 23 | 24 | /// 25 | /// Adds the specified public key to the application's JSON Web Key Set 26 | /// 27 | /// The public key to add 28 | void AddPublicKey(JsonWebKey key); 29 | 30 | /// 31 | /// Exports the application's JSON Web Key Set (JWKS) 32 | /// 33 | /// The JSON representation of the application's JWKS 34 | string Export(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/IPushNotificationSender.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Defines the fundamentals of a service used to send push notifications 18 | /// 19 | public interface IPushNotificationSender 20 | { 21 | 22 | /// 23 | /// Verifies the specified push notifications url 24 | /// 25 | /// The url to verify 26 | /// A 27 | /// A boolean indicating whether or not the push notification url could be verified 28 | Task VerifyPushNotificationUrlAsync(Uri url, CancellationToken cancellationToken = default); 29 | 30 | /// 31 | /// Sends a push notification to the specified url 32 | /// 33 | /// The url to send the push notification to 34 | /// The push notification's payload 35 | /// A 36 | /// A new awaitable 37 | System.Threading.Tasks.Task SendPushNotificationAsync(Uri url, object payload, CancellationToken cancellationToken = default); 38 | 39 | } -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/ITaskEventStream.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using System.Reactive.Subjects; 15 | 16 | namespace A2A.Server.Infrastructure.Services; 17 | 18 | /// 19 | /// Defines the fundamentals of a service used to stream task events 20 | /// 21 | public interface ITaskEventStream 22 | : ISubject 23 | { 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Services/ITaskHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Defines the fundamentals of a service used to handle tasks 18 | /// 19 | public interface ITaskHandler 20 | { 21 | 22 | /// 23 | /// Submits the specified task 24 | /// 25 | /// The task to submit 26 | /// A 27 | /// The submitted task 28 | Task SubmitAsync(TaskRecord task, CancellationToken cancellationToken = default); 29 | 30 | /// 31 | /// Cancels the specified task 32 | /// 33 | /// The task to cancel 34 | /// A message, if any, associated with the task's cancellation 35 | /// A 36 | /// The cancelled task 37 | Task CancelAsync(TaskRecord task, Message? message = null, CancellationToken cancellationToken = default); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/TaskRecord.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure; 15 | 16 | /// 17 | /// Represents the internal record of a task, extending the protocol-level task definition with additional runtime information such as push notification configuration 18 | /// 19 | [DataContract] 20 | public record TaskRecord 21 | : Models.Task 22 | { 23 | 24 | /// 25 | /// Gets/sets the task's message 26 | /// 27 | [Required] 28 | [DataMember(Name = "message", Order = 5), JsonPropertyName("message"), JsonPropertyOrder(5), YamlMember(Alias = "message", Order = 5)] 29 | public virtual Message Message { get; set; } = null!; 30 | 31 | /// 32 | /// Gets/sets the push notification configuration associated with the task, used to notify external systems about task updates 33 | /// 34 | [DataMember(Name = "notifications", Order = 6), JsonPropertyName("notifications"), JsonPropertyOrder(6), YamlMember(Alias = "notifications", Order = 6)] 35 | public virtual PushNotificationConfiguration? Notifications { get; set; } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Events; 15 | global using A2A.Models; 16 | global using Microsoft.Extensions.DependencyInjection; 17 | global using System.ComponentModel.DataAnnotations; 18 | global using System.Runtime.Serialization; 19 | global using System.Text.Json.Serialization; 20 | global using YamlDotNet.Serialization; 21 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.Abstractions/a2a-net.Server.Infrastructure.Abstractions.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.Server.Infrastructure 8 | 0.8.0 9 | $(VersionPrefix) 10 | $(VersionPrefix) 11 | en 12 | true 13 | True 14 | true 15 | A2A-NET Protocol Server - Infrastructure Abstractions 16 | Contains service abstractions used by the A2A server infrastructure 17 | a2a;server;infrastructure;abstractions 18 | true 19 | Apache-2.0 20 | README.md 21 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 22 | https://github.com/neuroglia-io/a2a 23 | https://github.com/neuroglia-io/a2a 24 | git 25 | embedded 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.DistributedCache/Extensions/IA2AProtocolServerBuilderExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using A2A.Server.Infrastructure.Services; 15 | 16 | namespace A2A.Server.Infrastructure; 17 | 18 | /// 19 | /// Defines extensions for s 20 | /// 21 | public static class IA2AProtocolServerBuilderExtensions 22 | { 23 | 24 | /// 25 | /// Configures the to use the 26 | /// 27 | /// The to configure 28 | /// The configured 29 | public static IA2AProtocolServerBuilder UseDistributedCacheTaskRepository(this IA2AProtocolServerBuilder builder) 30 | { 31 | builder.UseTaskRepository(); 32 | return builder; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/a2a-net.Server.Infrastructure.DistributedCache/a2a-net.Server.Infrastructure.DistributedCache.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.Server.Infrastructure.DistributedCache 8 | 0.8.0 9 | $(VersionPrefix) 10 | $(VersionPrefix) 11 | en 12 | true 13 | True 14 | true 15 | A2A-NET Protocol Server - Distributed Cache Infrastructure 16 | Contains a distributed cache implementation of the task repository 17 | a2a;server;infrastructure;cache;distributed 18 | true 19 | Apache-2.0 20 | README.md 21 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 22 | https://github.com/neuroglia-io/a2a 23 | https://github.com/neuroglia-io/a2a 24 | git 25 | embedded 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/a2a-net.Server/Extensions/TaskRecordExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server; 15 | 16 | /// 17 | /// Defines extensions for s 18 | /// 19 | public static class TaskRecordExtensions 20 | { 21 | 22 | /// 23 | /// Converts the into a new 24 | /// 25 | /// The to convert 26 | /// A boolean indicating whether or not the agent exposes status change history for tasks 27 | /// The maximum length number of state transitions, if any, to be retrieved 28 | /// A new 29 | public static Models.Task AsTask(this TaskRecord taskRecord, bool stateTransitionHistory = false, uint? historyLength = null) => new() 30 | { 31 | Id = taskRecord.Id, 32 | SessionId = taskRecord.SessionId, 33 | Status = taskRecord.Status, 34 | Artifacts = taskRecord.Artifacts, 35 | History = stateTransitionHistory ? historyLength.HasValue && taskRecord.History != null ? [..taskRecord.History.TakeLast((int)historyLength.Value)] : taskRecord.History : null, 36 | Metadata = taskRecord.Metadata, 37 | }; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/a2a-net.Server/Infrastructure/Services/A2AProtocolServerProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Represents the default implementation of the interface 18 | /// 19 | /// The current 20 | public class A2AProtocolServerProvider(IServiceProvider serviceProvider) 21 | : IA2AProtocolServerProvider 22 | { 23 | 24 | /// 25 | public virtual IA2AProtocolServer Get(string name) => serviceProvider.GetRequiredKeyedService(name); 26 | 27 | } -------------------------------------------------------------------------------- /src/a2a-net.Server/Infrastructure/Services/AgentProviderBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Represents the default implementation of the interface 18 | /// 19 | public class AgentProviderBuilder 20 | : IAgentProviderBuilder 21 | { 22 | 23 | /// 24 | /// Gets the to build and configure 25 | /// 26 | protected AgentProvider Provider { get; } = new(); 27 | 28 | /// 29 | public virtual IAgentProviderBuilder WithOrganization(string organization) 30 | { 31 | ArgumentException.ThrowIfNullOrWhiteSpace(organization); 32 | Provider.Organization = organization; 33 | return this; 34 | } 35 | 36 | /// 37 | public virtual IAgentProviderBuilder WithUrl(Uri url) 38 | { 39 | Provider.Url = url; 40 | return this; 41 | } 42 | 43 | /// 44 | public virtual AgentProvider Build() => Provider; 45 | 46 | } -------------------------------------------------------------------------------- /src/a2a-net.Server/Infrastructure/Services/AgentSkillBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.Server.Infrastructure.Services; 15 | 16 | /// 17 | /// Represents the default implementation of the interface 18 | /// 19 | public class AgentSkillBuilder 20 | : IAgentSkillBuilder 21 | { 22 | 23 | /// 24 | /// Gets the skill to build and configure 25 | /// 26 | protected AgentSkill Skill { get; } = new(); 27 | 28 | /// 29 | public virtual IAgentSkillBuilder WithId(string id) 30 | { 31 | ArgumentException.ThrowIfNullOrWhiteSpace(id); 32 | Skill.Id = id; 33 | return this; 34 | } 35 | 36 | /// 37 | public virtual IAgentSkillBuilder WithName(string name) 38 | { 39 | ArgumentException.ThrowIfNullOrWhiteSpace(name); 40 | Skill.Name = name; 41 | return this; 42 | } 43 | 44 | /// 45 | public virtual IAgentSkillBuilder WithDescription(string description) 46 | { 47 | Skill.Description = description; 48 | return this; 49 | } 50 | 51 | /// 52 | public virtual IAgentSkillBuilder WithTag(string tag) 53 | { 54 | ArgumentException.ThrowIfNullOrWhiteSpace(tag); 55 | Skill.Tags ??= []; 56 | if (!Skill.Tags.Contains(tag)) Skill.Tags.Add(tag); 57 | return this; 58 | } 59 | 60 | /// 61 | public virtual IAgentSkillBuilder WithExample(string example) 62 | { 63 | ArgumentException.ThrowIfNullOrWhiteSpace(example); 64 | Skill.Examples ??= []; 65 | Skill.Examples.Add(example); 66 | return this; 67 | } 68 | 69 | /// 70 | public virtual IAgentSkillBuilder WithInputMode(string contentType) 71 | { 72 | ArgumentException.ThrowIfNullOrWhiteSpace(contentType); 73 | Skill.InputModes ??= []; 74 | if (!Skill.InputModes.Contains(contentType)) Skill.InputModes.Add(contentType); 75 | return this; 76 | } 77 | 78 | /// 79 | public virtual IAgentSkillBuilder WithOutputMode(string contentType) 80 | { 81 | ArgumentException.ThrowIfNullOrWhiteSpace(contentType); 82 | Skill.OutputModes ??= []; 83 | if (!Skill.OutputModes.Contains(contentType)) Skill.OutputModes.Add(contentType); 84 | return this; 85 | } 86 | 87 | /// 88 | public virtual AgentSkill Build() => Skill; 89 | 90 | } -------------------------------------------------------------------------------- /src/a2a-net.Server/Infrastructure/Services/JsonWebKeySet.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using Microsoft.IdentityModel.Tokens; 15 | 16 | namespace A2A.Server.Infrastructure.Services; 17 | 18 | /// 19 | /// Represents the default implementation of the interface 20 | /// 21 | public class JsonWebKeySet 22 | : IJsonWebKeySet 23 | { 24 | 25 | /// 26 | /// Gets a list containing all registered public keys 27 | /// 28 | protected List PublicKeys { get; } = []; 29 | 30 | /// 31 | public virtual void AddPublicKey(JsonWebKey key) 32 | { 33 | ArgumentNullException.ThrowIfNull(key); 34 | PublicKeys.Add(key); 35 | } 36 | 37 | /// 38 | public virtual string Export() 39 | { 40 | var jwks = new 41 | { 42 | keys = PublicKeys 43 | }; 44 | return JsonSerializer.Serialize(jwks); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/a2a-net.Server/Infrastructure/Services/TaskEventStream.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using System.Reactive.Subjects; 15 | 16 | namespace A2A.Server.Infrastructure.Services; 17 | 18 | /// 19 | /// Represents the default implementation of the interface 20 | /// 21 | public class TaskEventStream 22 | : ITaskEventStream 23 | { 24 | 25 | /// 26 | /// Gets the used to stream s 27 | /// 28 | protected Subject Subject { get; } = new(); 29 | 30 | /// 31 | public virtual IDisposable Subscribe(IObserver observer) => Subject.Subscribe(observer); 32 | 33 | /// 34 | public virtual void OnNext(TaskEvent value) => Subject.OnNext(value); 35 | 36 | /// 37 | public virtual void OnCompleted() => Subject.OnCompleted(); 38 | 39 | /// 40 | public virtual void OnError(Exception error) => Subject.OnError(error); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/a2a-net.Server/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Errors; 15 | global using A2A.Events; 16 | global using A2A.Models; 17 | global using A2A.Requests; 18 | global using A2A.Server.Infrastructure; 19 | global using A2A.Server.Infrastructure.Services; 20 | global using Microsoft.Extensions.DependencyInjection; 21 | global using Microsoft.Extensions.DependencyInjection.Extensions; 22 | global using Microsoft.Extensions.Logging; 23 | global using StreamJsonRpc; 24 | global using System.Net.Mime; 25 | global using System.Reactive.Linq; 26 | global using System.Runtime.CompilerServices; 27 | global using System.Text; 28 | global using System.Text.Json; -------------------------------------------------------------------------------- /src/a2a-net.Server/a2a-net.Server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.Server 8 | 0.8.0 9 | $(VersionPrefix) 10 | $(VersionPrefix) 11 | en 12 | true 13 | True 14 | true 15 | A2A-NET Protocol Server 16 | Contains the A2A Protocol server 17 | a2a;server 18 | true 19 | Apache-2.0 20 | README.md 21 | Copyright © 2025-Present the a2a-net Authors. All rights reserved. 22 | https://github.com/neuroglia-io/a2a 23 | https://github.com/neuroglia-io/a2a 24 | git 25 | embedded 26 | 27 | 28 | 29 | 30 | True 31 | \ 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/a2a-net.IntegrationTests/A2AWebServerStartup.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using A2A.Server.AspNetCore; 15 | using Microsoft.AspNetCore.Builder; 16 | using Microsoft.AspNetCore.Hosting; 17 | 18 | namespace A2A.IntegrationTests; 19 | 20 | public class A2AWebServerStartup 21 | : StartupBase 22 | { 23 | 24 | public override void ConfigureServices(IServiceCollection services) 25 | { 26 | services.AddLogging(); 27 | services.AddA2AWellKnownAgent((provider, agent) => agent 28 | .WithName("fake-agent-1") 29 | .WithDescription("fake-agent-1-description") 30 | .WithVersion("1.0.0") 31 | .WithUrl(new("http://localhost/a2a/fake-agent")) 32 | .WithProvider(provider => provider 33 | .WithOrganization("Neuroglia SRL") 34 | .WithUrl(new("https://neuroglia.io"))) 35 | .WithSkill(skill => skill 36 | .WithId("fake-skill-id") 37 | .WithName("fake-skill-name") 38 | .WithDescription("fake-skill-description"))); 39 | services.AddA2AWellKnownAgent((provider, agent) => agent 40 | .WithName("fake-agent-2") 41 | .WithDescription("fake-agent-2-description") 42 | .WithVersion("1.0.0") 43 | .WithUrl(new("http://localhost/a2a/fake-agent")) 44 | .WithProvider(provider => provider 45 | .WithOrganization("Neuroglia SRL") 46 | .WithUrl(new("https://neuroglia.io"))) 47 | .WithSkill(skill => skill 48 | .WithId("fake-skill-id") 49 | .WithName("fake-skill-name") 50 | .WithDescription("fake-skill-description"))); 51 | services.AddDistributedMemoryCache(); 52 | services.AddA2AProtocolServer(builder => 53 | { 54 | builder 55 | .SupportsStreaming() 56 | .SupportsPushNotifications() 57 | .SupportsStateTransitionHistory() 58 | .UseAgentRuntime() 59 | .UseDistributedCacheTaskRepository() 60 | .UsePushNotificationSender(); 61 | }); 62 | } 63 | 64 | public override void Configure(IApplicationBuilder app) 65 | { 66 | app.UseRouting(); 67 | app.MapA2AWellKnownAgentEndpoint(); 68 | app.UseEndpoints(endpoints => 69 | { 70 | endpoints.MapA2AHttpEndpoint("/a2a"); 71 | endpoints.MapA2AWebSocketEndpoint("/a2a/ws"); 72 | }); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /tests/a2a-net.IntegrationTests/Cases/A2ADiscoveryTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.IntegrationTests.Cases; 15 | 16 | public class A2ADiscoveryTests 17 | : IClassFixture 18 | { 19 | 20 | public A2ADiscoveryTests(A2AWebServerFactory webServerFactory) 21 | { 22 | WebServerFactory = webServerFactory; 23 | } 24 | 25 | A2AWebServerFactory WebServerFactory { get; } 26 | 27 | [Fact] 28 | public async System.Threading.Tasks.Task Get_AgentsDocumentation_Should_Work() 29 | { 30 | //arrange 31 | using var httpClient = WebServerFactory.CreateClient(); 32 | 33 | //act 34 | var agents = await httpClient.GetFromJsonAsync>("/.well-known/agents.json"); 35 | 36 | //assert 37 | agents.Should().NotBeNullOrEmpty(); 38 | } 39 | 40 | [Fact] 41 | public async System.Threading.Tasks.Task Get_AgentsDocumentation_Using_DiscoveryClient_Should_Work() 42 | { 43 | //arrange 44 | using var httpClient = WebServerFactory.CreateClient(); 45 | 46 | //act 47 | var document = await httpClient.GetA2ADiscoveryDocumentAsync(); 48 | 49 | //assert 50 | document.Should().NotBeNull(); 51 | document.Endpoint.AbsoluteUri.Should().Be($"{WebServerFactory.Server.BaseAddress}.well-known/agents.json"); 52 | document.Agents.Should().NotBeNullOrEmpty(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/a2a-net.IntegrationTests/Services/A2AWebServerFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using Microsoft.AspNetCore.Mvc.Testing; 15 | using Microsoft.AspNetCore.Hosting; 16 | using Microsoft.AspNetCore; 17 | using Microsoft.Extensions.Hosting; 18 | 19 | namespace A2A.IntegrationTests.Services; 20 | 21 | public class A2AWebServerFactory 22 | : WebApplicationFactory 23 | { 24 | 25 | protected override void ConfigureWebHost(IWebHostBuilder builder) 26 | { 27 | builder.UseContentRoot(""); 28 | } 29 | 30 | protected override IWebHostBuilder? CreateWebHostBuilder() 31 | { 32 | return WebHost.CreateDefaultBuilder().UseStartup(); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /tests/a2a-net.IntegrationTests/Services/MockAgentRuntime.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using System.Runtime.CompilerServices; 15 | 16 | namespace A2A.IntegrationTests.Services; 17 | 18 | internal class MockAgentRuntime 19 | : IAgentRuntime 20 | { 21 | 22 | public async IAsyncEnumerable ExecuteAsync(TaskRecord task, [EnumeratorCancellation] CancellationToken cancellationToken = default) 23 | { 24 | await System.Threading.Tasks.Task.Delay(50, cancellationToken); 25 | yield return new(new Artifact() 26 | { 27 | Parts = 28 | [ 29 | new TextPart("Foo") 30 | ] 31 | }); 32 | yield return new(new Artifact() 33 | { 34 | Parts = 35 | [ 36 | new TextPart("Bar") 37 | ] 38 | }); 39 | yield return new(new Artifact() 40 | { 41 | Parts = 42 | [ 43 | new TextPart("Baz") 44 | ] 45 | }); 46 | } 47 | 48 | public System.Threading.Tasks.Task CancelAsync(string taskId, CancellationToken cancellationToken = default) => System.Threading.Tasks.Task.CompletedTask; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /tests/a2a-net.IntegrationTests/Services/TestPushNotificationSender.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.IntegrationTests.Services; 15 | 16 | public class TestPushNotificationSender 17 | : IPushNotificationSender 18 | { 19 | 20 | public System.Threading.Tasks.Task SendPushNotificationAsync(Uri url, object payload, CancellationToken cancellationToken = default) => System.Threading.Tasks.Task.CompletedTask; 21 | 22 | public virtual Task VerifyPushNotificationUrlAsync(Uri url, CancellationToken cancellationToken = default) => System.Threading.Tasks.Task.FromResult(true); 23 | 24 | } -------------------------------------------------------------------------------- /tests/a2a-net.IntegrationTests/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Client.Services; 15 | global using A2A.IntegrationTests.Services; 16 | global using A2A.Models; 17 | global using A2A.Requests; 18 | global using A2A.Server; 19 | global using A2A.Server.Infrastructure; 20 | global using A2A.Server.Infrastructure.Services; 21 | global using A2A.Client; 22 | global using FluentAssertions; 23 | global using Microsoft.Extensions.DependencyInjection; 24 | global using System.Net.Http.Json; 25 | -------------------------------------------------------------------------------- /tests/a2a-net.IntegrationTests/a2a-net.IntegrationTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | A2A.IntegrationTests 8 | false 9 | true 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | all 25 | runtime; build; native; contentfiles; analyzers; buildtransitive 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 9.0.4 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Services/AuthenticationInfoFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.UnitTests.Services; 15 | 16 | internal static class AuthenticationInfoFactory 17 | { 18 | 19 | internal static AuthenticationInfo Create() => new() 20 | { 21 | Schemes = ["OAuth2"], 22 | Credentials = "fake-credentials" 23 | }; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Services/FileFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.UnitTests.Services; 15 | 16 | internal static class FileFactory 17 | { 18 | 19 | internal static Models.File Create() => new() 20 | { 21 | Name = "fake-file", 22 | MimeType = "fake-mime-type", 23 | Bytes = "fake-file-content", 24 | Uri = new("https://fake.com") 25 | }; 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Services/MessageFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.UnitTests.Services; 15 | 16 | internal static class MessageFactory 17 | { 18 | 19 | internal static Message Create() => new() 20 | { 21 | Role = MessageRole.User, 22 | Parts = PartFactory.CreateCollection() 23 | }; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Services/MetadataFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using System.Text.Json; 15 | 16 | namespace A2A.UnitTests.Services; 17 | 18 | internal static class MetadataFactory 19 | { 20 | 21 | internal static EquatableDictionary Create() => new() 22 | { 23 | { "fakeMetadata", JsonSerializer.SerializeToElement("fakeMetadataValue") } 24 | }; 25 | 26 | } -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Services/PartFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | using System.Text.Json; 15 | 16 | namespace A2A.UnitTests.Services; 17 | 18 | internal static class PartFactory 19 | { 20 | 21 | internal static FilePart CreateFilePart() => new() 22 | { 23 | File = FileFactory.Create() 24 | }; 25 | 26 | internal static DataPart CreateDataPart() => new() 27 | { 28 | Data = new() 29 | { 30 | { "fake-data", JsonSerializer.SerializeToElement("fake-data-value") } 31 | } 32 | }; 33 | 34 | internal static TextPart CreateTextPart() => new() 35 | { 36 | Text = "fake-text" 37 | }; 38 | 39 | internal static EquatableList CreateCollection() => [CreateFilePart(), CreateDataPart(), CreateTextPart()]; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Services/PushNotificationConfigurationFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.UnitTests.Services; 15 | 16 | internal static class PushNotificationConfigurationFactory 17 | { 18 | 19 | internal static PushNotificationConfiguration Create() => new() 20 | { 21 | Url = new("https://fake.com"), 22 | Token = "fake-token", 23 | Authentication = AuthenticationInfoFactory.Create() 24 | }; 25 | 26 | } -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Services/TaskFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.UnitTests.Services; 15 | 16 | internal static class TaskFactory 17 | { 18 | 19 | internal static Models.Task Create() => new() 20 | { 21 | Id = Guid.NewGuid().ToString("N"), 22 | Status = TaskStatusFactory.Create() 23 | }; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Services/TaskStatusFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | namespace A2A.UnitTests.Services; 15 | 16 | internal static class TaskStatusFactory 17 | { 18 | 19 | internal static Models.TaskStatus Create() => new() 20 | { 21 | State = TaskState.Submitted, 22 | Message = MessageFactory.Create(), 23 | Timestamp = DateTimeOffset.Now 24 | }; 25 | 26 | } -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/Usings.cs: -------------------------------------------------------------------------------- 1 | // Copyright � 2025-Present the a2a-net Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"), 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | global using A2A.Models; 15 | global using A2A.Requests; 16 | global using A2A.UnitTests.Services; 17 | global using FluentAssertions; 18 | global using Neuroglia; -------------------------------------------------------------------------------- /tests/a2a-net.UnitTests/a2a-net.UnitTests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | enable 6 | enable 7 | A2A.UnitTests 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | --------------------------------------------------------------------------------