Skip to content

Introducing .NET SDK Integration for Agent Protocol #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
223 changes: 223 additions & 0 deletions packages/sdk/C#/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true

[*]
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true
indent_style = space
indent_size = 4
tab_width = 4

[{*.yml,*.yaml,*.har,*.inputactions,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}]
indent_size = 2

[{*.xml,*.csproj}]
indent_size = 2
ij_xml_space_inside_empty_tag = true

# C# files
[*.cs]
max_line_length = 140
insert_final_newline = false
trim_trailing_whitespace = true

#### .NET Coding Conventions ####

dotnet_sort_system_directives_first = true

# this. and Me. preferences
dotnet_style_qualification_for_event = false:warning
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_property = false:warning

# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:suggestion
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion

# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning

# Expression-level preferences
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_throw_expression = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_null_propagation = true:suggestion
dotnet_style_object_initializer = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion

# Field preferences
dotnet_style_readonly_field = true:suggestion

# Parameter preferences
dotnet_code_quality_unused_parameters = all:warning

#### .NET Naming Rules ####

dotnet_naming_rule.constant_rule.severity = warning
dotnet_naming_rule.constant_rule.symbols = constant
dotnet_naming_rule.constant_rule.style = underscore_case
dotnet_naming_symbols.constant.applicable_kinds = field
dotnet_naming_symbols.constant.applicable_accessibilities = *
dotnet_naming_symbols.constant.required_modifiers = const
dotnet_naming_style.underscore_case.word_separator = _
dotnet_naming_style.underscore_case.capitalization = all_upper

dotnet_naming_rule.interface_rule.severity = warning
dotnet_naming_rule.interface_rule.symbols = interface
dotnet_naming_rule.interface_rule.style = interface
dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = *
dotnet_naming_style.interface.required_prefix = I
dotnet_naming_style.interface.capitalization = pascal_case

dotnet_naming_rule.types_rule.severity = warning
dotnet_naming_rule.types_rule.symbols = types
dotnet_naming_rule.types_rule.style = pascal_case
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = *
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_rule.non_field_members_rule.severity = warning
dotnet_naming_rule.non_field_members_rule.symbols = non_field_members
dotnet_naming_rule.non_field_members_rule.style = pascal_case
dotnet_naming_symbols.non_field_members.applicable_kinds = property, method, event
dotnet_naming_symbols.non_field_members.applicable_accessibilities = *

dotnet_naming_rule.type_parameter_rule.severity = warning
dotnet_naming_rule.type_parameter_rule.symbols = type_parameter
dotnet_naming_rule.type_parameter_rule.style = pascal_case
dotnet_naming_symbols.type_parameter.applicable_kinds = type_parameter
dotnet_naming_symbols.type_parameter.applicable_accessibilities = *

dotnet_naming_rule.private_or_internal_field_rule.severity = warning
dotnet_naming_rule.private_or_internal_field_rule.symbols = private_or_internal_field
dotnet_naming_rule.private_or_internal_field_rule.style = private_or_internal_field
dotnet_naming_symbols.private_or_internal_field.applicable_kinds = field
dotnet_naming_symbols.private_or_internal_field.applicable_accessibilities = private, internal
dotnet_naming_style.private_or_internal_field.required_prefix = _
dotnet_naming_style.private_or_internal_field.capitalization = camel_case

dotnet_naming_rule.parameter_rule.severity = warning
dotnet_naming_rule.parameter_rule.symbols = parameter
dotnet_naming_rule.parameter_rule.style = camel_case
dotnet_naming_symbols.parameter.applicable_kinds = parameter
dotnet_naming_symbols.parameter.applicable_accessibilities = *
dotnet_naming_style.camel_case.capitalization = camel_case

#### C# Coding Conventions ####

# var preferences
csharp_style_var_elsewhere = false:warning
csharp_style_var_for_built_in_types = false:warning
csharp_style_var_when_type_is_apparent = false:warning

# Expression-bodied members
csharp_style_expression_bodied_accessors = false:suggestion
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_lambdas = when_on_single_line:suggestion
csharp_style_expression_bodied_local_functions = false:suggestion
csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_operators = false:suggestion
csharp_style_expression_bodied_properties = true:suggestion

# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true:warning
csharp_style_pattern_matching_over_is_with_cast_check = true:warning

# Null-checking preferences
csharp_style_conditional_delegate_call = true:suggestion

# Modifier preferences
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async

# Code-block preferences
csharp_prefer_braces = true:warning

# Expression-level preferences
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:silent
csharp_style_unused_value_expression_statement_preference = discard_variable:silent

#### C# Formatting Rules ####

# New line preferences
csharp_new_line_before_catch = true
csharp_new_line_before_else = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true

# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true

# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false

# Wrapping preferences
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = false
csharp_prefer_simple_using_statement = false:suggestion

# ReSharper inspection severities
resharper_csharp_object_creation_when_type_evident = target_typed
resharper_csharp_object_creation_when_type_not_evident = explicitly_typed
resharper_arrange_object_creation_when_type_evident_highlighting = suggestion
resharper_arrange_object_creation_when_type_not_evident_highlighting = suggestion
resharper_csharp_blank_lines_after_file_scoped_namespace_directive = 1
resharper_not_accessed_field_local_highlighting = suggestion
resharper_unused_member_local_highlighting = suggestion
resharper_spec_flow_step_not_resolved_highlighting = suggestion
resharper_unused_auto_property_accessor_global_highlighting = suggestion
resharper_unused_member_local_highlighting = suggestion
resharper_blank_lines_before_block_statements = 1
resharper_max_attribute_length_for_same_line = 120
resharper_place_accessorholder_attribute_on_same_line = false
resharper_place_field_attribute_on_same_line = false
resharper_entity_framework_n_plus_one_incomplete_data_usage_highlighting = hint
54 changes: 54 additions & 0 deletions packages/sdk/C#/AgentProtocolSdk.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{EAB2C585-38C6-436C-ABCA-357296235302}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication", "Examples\ConsoleApplication\ConsoleApplication.csproj", "{D7A41B8F-4BD5-4355-AFB4-FBF25A0CAD8D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator", "Generator\Generator.csproj", "{3405EF12-B29F-4420-8D4B-43B36F8CF63F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{2EE65CA0-4396-406B-9244-6D1E84BB2E24}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{18315049-926C-4168-A336-55F85DC8D5B5}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
.editorconfig = .editorconfig
.gitignore = .gitignore
AgentProtocolSdk.sln = AgentProtocolSdk.sln
Directory.Packages.props = Directory.Packages.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Library", "Library\Library.csproj", "{65A4ED0F-B1ED-4B9C-93E7-43EBE2855496}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D7A41B8F-4BD5-4355-AFB4-FBF25A0CAD8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7A41B8F-4BD5-4355-AFB4-FBF25A0CAD8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7A41B8F-4BD5-4355-AFB4-FBF25A0CAD8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7A41B8F-4BD5-4355-AFB4-FBF25A0CAD8D}.Release|Any CPU.Build.0 = Release|Any CPU
{3405EF12-B29F-4420-8D4B-43B36F8CF63F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3405EF12-B29F-4420-8D4B-43B36F8CF63F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3405EF12-B29F-4420-8D4B-43B36F8CF63F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3405EF12-B29F-4420-8D4B-43B36F8CF63F}.Release|Any CPU.Build.0 = Release|Any CPU
{2EE65CA0-4396-406B-9244-6D1E84BB2E24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2EE65CA0-4396-406B-9244-6D1E84BB2E24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2EE65CA0-4396-406B-9244-6D1E84BB2E24}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2EE65CA0-4396-406B-9244-6D1E84BB2E24}.Release|Any CPU.Build.0 = Release|Any CPU
{65A4ED0F-B1ED-4B9C-93E7-43EBE2855496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65A4ED0F-B1ED-4B9C-93E7-43EBE2855496}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65A4ED0F-B1ED-4B9C-93E7-43EBE2855496}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65A4ED0F-B1ED-4B9C-93E7-43EBE2855496}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D7A41B8F-4BD5-4355-AFB4-FBF25A0CAD8D} = {EAB2C585-38C6-436C-ABCA-357296235302}
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions packages/sdk/C#/AgentProtocolSdk.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeEditing/SuppressNullableWarningFix/Enabled/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=appsettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
4 changes: 4 additions & 0 deletions packages/sdk/C#/AgentProtocolSdk.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=4ee393d5_002D6a6f_002D45dd_002Da7e7_002D8e5328955054/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &amp;lt;Tests&amp;gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Project Location="B:\root\agent-protocol\packages\sdk\C#\Tests" Presentation="&amp;lt;Tests&amp;gt;" /&gt;&#xD;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>
21 changes: 21 additions & 0 deletions packages/sdk/C#/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="CommandLineParser" Version="2.9.1"/>
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0"/>
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0"/>
<PackageVersion Include="NSwag.CodeGeneration.CSharp" Version="14.0.3"/>
<PackageVersion Include="NSwag.Core" Version="14.0.3"/>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageVersion Include="xunit" Version="2.6.1"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3"/>
<PackageVersion Include="Moq" Version="4.20.69"/>
<PackageVersion Include="FluentAssertions" Version="6.12.0"/>
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageVersion Include="Spectre.Console" Version="0.48.0" />
</ItemGroup>
</Project>
49 changes: 49 additions & 0 deletions packages/sdk/C#/Examples/ConsoleApplication/AgentTaskModels.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ReSharper disable All
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
namespace ConsoleApplication
{
// Simplified model classes that wrap the SDK response types
// to make them easier to use in the console application

public class AgentTask
{
public string Id { get; set; }
public string Input { get; set; }
public string Status { get; set; }
public DateTime CreatedAt { get; set; }
public List<AgentArtifact> Artifacts { get; set; } = new();
}

public class AgentStep
{
public string Id { get; set; }
public string TaskId { get; set; }
public string Input { get; set; }
public string Output { get; set; }
public string Status { get; set; }
public object AdditionalOutput { get; set; }
public bool IsLast { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? ExecutedAt { get; set; }
public List<AgentArtifact> Artifacts { get; set; } = new();
}

public class AgentArtifact
{
public string Id { get; set; }
public bool AgentCreated { get; set; }
public string FileName { get; set; }
public string RelativePath { get; set; }
public long Size { get; set; }
public DateTime CreatedAt { get; set; }
}

public class PaginatedData<T>
{
public List<T> Data { get; set; } = new();
public int TotalCount { get; set; }
public int CurrentPage { get; set; }
public int PageSize { get; set; }
public int TotalPages { get; set; }
}
}
Loading