diff --git a/packages/sdk/C#/.editorconfig b/packages/sdk/C#/.editorconfig
new file mode 100644
index 00000000..a73739d0
--- /dev/null
+++ b/packages/sdk/C#/.editorconfig
@@ -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
diff --git a/packages/sdk/C#/AgentProtocolSdk.sln b/packages/sdk/C#/AgentProtocolSdk.sln
new file mode 100644
index 00000000..dedfc10f
--- /dev/null
+++ b/packages/sdk/C#/AgentProtocolSdk.sln
@@ -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
diff --git a/packages/sdk/C#/AgentProtocolSdk.sln.DotSettings b/packages/sdk/C#/AgentProtocolSdk.sln.DotSettings
new file mode 100644
index 00000000..8359f72b
--- /dev/null
+++ b/packages/sdk/C#/AgentProtocolSdk.sln.DotSettings
@@ -0,0 +1,3 @@
+
+ False
+ True
\ No newline at end of file
diff --git a/packages/sdk/C#/AgentProtocolSdk.sln.DotSettings.user b/packages/sdk/C#/AgentProtocolSdk.sln.DotSettings.user
new file mode 100644
index 00000000..38834976
--- /dev/null
+++ b/packages/sdk/C#/AgentProtocolSdk.sln.DotSettings.user
@@ -0,0 +1,4 @@
+
+ <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from <Tests>" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <Project Location="B:\root\agent-protocol\packages\sdk\C#\Tests" Presentation="<Tests>" />
+</SessionState>
\ No newline at end of file
diff --git a/packages/sdk/C#/Directory.Packages.props b/packages/sdk/C#/Directory.Packages.props
new file mode 100644
index 00000000..c846d109
--- /dev/null
+++ b/packages/sdk/C#/Directory.Packages.props
@@ -0,0 +1,21 @@
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/sdk/C#/Examples/ConsoleApplication/AgentTaskModels.cs b/packages/sdk/C#/Examples/ConsoleApplication/AgentTaskModels.cs
new file mode 100644
index 00000000..5574ee74
--- /dev/null
+++ b/packages/sdk/C#/Examples/ConsoleApplication/AgentTaskModels.cs
@@ -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 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 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
+ {
+ public List Data { get; set; } = new();
+ public int TotalCount { get; set; }
+ public int CurrentPage { get; set; }
+ public int PageSize { get; set; }
+ public int TotalPages { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Examples/ConsoleApplication/AgentTaskService.cs b/packages/sdk/C#/Examples/ConsoleApplication/AgentTaskService.cs
new file mode 100644
index 00000000..009e429c
--- /dev/null
+++ b/packages/sdk/C#/Examples/ConsoleApplication/AgentTaskService.cs
@@ -0,0 +1,409 @@
+using AnotherAgentProtocolLibrary;
+#pragma warning disable CS8601 // Possible null reference assignment.
+
+namespace ConsoleApplication
+{
+ public class AgentTaskService : IAgentTaskService
+ {
+ private readonly IApiClient _apiClient;
+
+ public AgentTaskService(IApiClient apiClient)
+ {
+ _apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
+ }
+
+ public async Task CreateTaskAsync(string input, object? additionalInput = null)
+ {
+ Body body = new() { Input = input };
+ if (additionalInput != null)
+ {
+ body.Additional_input = additionalInput;
+ }
+
+ Response response = await _apiClient.CreateAgentTaskAsync(body);
+ return MapToAgentTask(response);
+ }
+
+ public async Task> GetTasksAsync(int? page = null, int? pageSize = null)
+ {
+ Response2 response = await _apiClient.ListAgentTasksAsync(page, pageSize);
+
+ PaginatedData result = new()
+ {
+ CurrentPage = response.Pagination.Current_page,
+ PageSize = response.Pagination.Page_size,
+ TotalCount = response.Pagination.Total_items,
+ TotalPages = response.Pagination.Total_pages,
+ };
+
+ return result;
+ }
+
+ public async Task GetTaskAsync(string taskId)
+ {
+ Response3 response = await _apiClient.GetAgentTaskAsync(taskId);
+ return MapToAgentTask(response);
+ }
+
+ public async Task> GetTaskStepsAsync(string taskId, int? page = null, int? pageSize = null)
+ {
+ Response4 response = await _apiClient.ListAgentTaskStepsAsync(taskId, page, pageSize);
+
+ PaginatedData result = new()
+ {
+ CurrentPage = response.Pagination.Current_page,
+ PageSize = response.Pagination.Page_size,
+ TotalCount = response.Pagination.Total_items,
+ TotalPages = response.Pagination.Total_pages,
+ };
+
+ return result;
+ }
+
+ public async Task ExecuteTaskStepAsync(string taskId, string input, object? additionalInput = null)
+ {
+ Body2 body = new() { Input = input };
+ if (additionalInput != null)
+ {
+ body.Additional_input = additionalInput;
+ }
+
+ Response5 response = await _apiClient.ExecuteAgentTaskStepAsync(taskId, body);
+ return MapToAgentStep(response);
+ }
+
+ public async Task GetTaskStepAsync(string taskId, string stepId)
+ {
+ Response6 response = await _apiClient.GetAgentTaskStepAsync(taskId, stepId);
+ return MapToAgentStep(response);
+ }
+
+ public async Task> GetTaskArtifactsAsync(string taskId, int? page = null, int? pageSize = null)
+ {
+ Response7 response = await _apiClient.ListAgentTaskArtifactsAsync(taskId, page, pageSize);
+
+ PaginatedData result = new()
+ {
+ CurrentPage = response.Pagination.Current_page,
+ PageSize = response.Pagination.Page_size,
+ TotalCount = response.Pagination.Total_items,
+ TotalPages = response.Pagination.Total_pages,
+ Data = response.Artifacts.Select(MapToAgentArtifact).ToList()
+ };
+
+ return result;
+ }
+
+ public async Task UploadArtifactAsync(string taskId, string filePath, string relativePath)
+ {
+ // Read the file
+ byte[] fileBytes = await File.ReadAllBytesAsync(filePath);
+ string fileName = Path.GetFileName(filePath);
+
+ // Create FileParameter
+ FileParameter fileParameter = new(
+ new MemoryStream(fileBytes),
+ fileName,
+ GetMimeType(fileName)
+ );
+
+ Response8 response = await _apiClient.UploadAgentTaskArtifactsAsync(taskId, fileParameter, relativePath);
+ return MapToAgentArtifact(response);
+ }
+
+ public async Task DownloadArtifactAsync(string taskId, string artifactId, string outputPath)
+ {
+ FileResponse response = await _apiClient.DownloadAgentTaskArtifactAsync(taskId, artifactId);
+
+ await using (FileStream fileStream = File.Create(outputPath))
+ {
+ await response.Stream.CopyToAsync(fileStream);
+ }
+
+ return new FileInfo(outputPath);
+ }
+
+ #region Helper Methods
+
+ private AgentTask MapToAgentTask(Response response)
+ {
+ return new AgentTask
+ {
+ Id = response.Task_id,
+ Input = response.Input,
+ Status = "Created", // Assuming status from Response, which isn't explicitly defined in SDK
+ CreatedAt = DateTime.Now, // SDK doesn't appear to provide creation time in the response
+ Artifacts = response.Artifacts?.Select(MapToAgentArtifact).ToList() ?? []
+ };
+ }
+
+ private AgentTask MapToAgentTask(Response3 response)
+ {
+ return new AgentTask
+ {
+ Id = response.Task_id,
+ Input = response.Input,
+ Status = "Active", // Assuming status
+ CreatedAt = DateTime.Now, // SDK doesn't appear to provide creation time
+ Artifacts = response.Artifacts?.Select(MapToAgentArtifact).ToList() ?? []
+ };
+ }
+
+ private AgentTask MapToAgentTask(Tasks task)
+ {
+ return new AgentTask
+ {
+ Id = task.Task_id,
+ Input = task.Input,
+ Status = "Active", // Assuming status
+ CreatedAt = DateTime.Now, // Not provided in SDK
+ Artifacts = task.Artifacts?.Select(MapToAgentArtifact).ToList() ?? []
+ };
+ }
+
+ private AgentStep MapToAgentStep(Response5 response)
+ {
+ return new AgentStep
+ {
+ Id = response.Step_id,
+ TaskId = response.Task_id,
+ Input = response.Input,
+ Output = response.Output,
+ Status = response.Status.ToString(),
+ AdditionalOutput = response.Additional_output,
+ IsLast = response.Is_last,
+ CreatedAt = DateTime.Now, // Not provided in SDK
+ ExecutedAt = DateTime.Now, // Assuming just executed
+ Artifacts = response.Artifacts?.Select(MapToAgentArtifact).ToList() ?? []
+ };
+ }
+
+ private AgentStep MapToAgentStep(Response6 response)
+ {
+ return new AgentStep
+ {
+ Id = response.Step_id,
+ TaskId = response.Task_id,
+ Input = response.Input,
+ Output = response.Output,
+ Status = response.Status.ToString(),
+ AdditionalOutput = response.Additional_output,
+ IsLast = response.Is_last,
+ CreatedAt = DateTime.Now, // Not provided in SDK
+ ExecutedAt = response.Status == Response6Status.Completed ? DateTime.Now : null,
+ Artifacts = response.Artifacts?.Select(MapToAgentArtifact).ToList() ?? []
+ };
+ }
+
+ private AgentStep MapToAgentStep(Steps step)
+ {
+ return new AgentStep
+ {
+ Id = step.Step_id,
+ TaskId = step.Task_id,
+ Input = step.Input,
+ Output = step.Output,
+ Status = step.Status.ToString(),
+ AdditionalOutput = step.Additional_output,
+ IsLast = step.Is_last,
+ CreatedAt = DateTime.Now, // Not provided in SDK
+ ExecutedAt = step.Status == StepsStatus.Completed ? DateTime.Now : null,
+ Artifacts = step.Artifacts?.Select(MapToAgentArtifact).ToList() ?? []
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0, // Size not provided in SDK
+ CreatedAt = DateTime.Now // Not provided in SDK
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts2 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0, // Size not provided
+ CreatedAt = DateTime.Now // Not provided
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts3 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0, // Size not provided
+ CreatedAt = DateTime.Now // Not provided
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts4 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0,
+ CreatedAt = DateTime.Now
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts5 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0,
+ CreatedAt = DateTime.Now
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts6 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0,
+ CreatedAt = DateTime.Now
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts7 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0,
+ CreatedAt = DateTime.Now
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts8 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0,
+ CreatedAt = DateTime.Now
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts9 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0,
+ CreatedAt = DateTime.Now
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts10 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0,
+ CreatedAt = DateTime.Now
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(artifacts11 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0,
+ CreatedAt = DateTime.Now
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(Response8 artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0, // Not available in response
+ CreatedAt = DateTime.Now // Not available in response
+ };
+ }
+
+ private AgentArtifact MapToAgentArtifact(Artifacts artifact)
+ {
+ return new AgentArtifact
+ {
+ Id = artifact.Artifact_id,
+ AgentCreated = artifact.Agent_created,
+ FileName = artifact.File_name,
+ RelativePath = artifact.Relative_path,
+ Size = 0, // Not available
+ CreatedAt = DateTime.Now // Not available
+ };
+ }
+
+ private string GetMimeType(string fileName)
+ {
+ string extension = Path.GetExtension(fileName).ToLowerInvariant();
+
+ return extension switch
+ {
+ ".txt" => "text/plain",
+ ".pdf" => "application/pdf",
+ ".doc" => "application/msword",
+ ".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+ ".xls" => "application/vnd.ms-excel",
+ ".xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ ".png" => "image/png",
+ ".jpg" or ".jpeg" => "image/jpeg",
+ ".gif" => "image/gif",
+ ".csv" => "text/csv",
+ ".json" => "application/json",
+ ".xml" => "application/xml",
+ ".zip" => "application/zip",
+ _ => "application/octet-stream"
+ };
+ }
+
+ #endregion
+ }
+}
diff --git a/packages/sdk/C#/Examples/ConsoleApplication/ConsoleApplication.csproj b/packages/sdk/C#/Examples/ConsoleApplication/ConsoleApplication.csproj
new file mode 100644
index 00000000..fa00ff37
--- /dev/null
+++ b/packages/sdk/C#/Examples/ConsoleApplication/ConsoleApplication.csproj
@@ -0,0 +1,29 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/sdk/C#/Examples/ConsoleApplication/IAgentTaskService.cs b/packages/sdk/C#/Examples/ConsoleApplication/IAgentTaskService.cs
new file mode 100644
index 00000000..59cf193b
--- /dev/null
+++ b/packages/sdk/C#/Examples/ConsoleApplication/IAgentTaskService.cs
@@ -0,0 +1,15 @@
+namespace ConsoleApplication;
+
+#pragma warning disable CS8601
+public interface IAgentTaskService
+{
+ Task CreateTaskAsync(string input, object? additionalInput = null);
+ Task> GetTasksAsync(int? page = null, int? pageSize = null);
+ Task GetTaskAsync(string taskId);
+ Task> GetTaskStepsAsync(string taskId, int? page = null, int? pageSize = null);
+ Task ExecuteTaskStepAsync(string taskId, string input, object? additionalInput = null);
+ Task GetTaskStepAsync(string taskId, string stepId);
+ Task> GetTaskArtifactsAsync(string taskId, int? page = null, int? pageSize = null);
+ Task UploadArtifactAsync(string taskId, string filePath, string relativePath);
+ Task DownloadArtifactAsync(string taskId, string artifactId, string outputPath);
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Examples/ConsoleApplication/Program.cs b/packages/sdk/C#/Examples/ConsoleApplication/Program.cs
new file mode 100644
index 00000000..48557ec7
--- /dev/null
+++ b/packages/sdk/C#/Examples/ConsoleApplication/Program.cs
@@ -0,0 +1,514 @@
+using System.Net.Http.Headers;
+using AnotherAgentProtocolLibrary;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Spectre.Console;
+using Task = System.Threading.Tasks.Task;
+// ReSharper disable All
+
+namespace ConsoleApplication;
+
+public class Program
+{
+ public static async Task Main(string[] args)
+ {
+ try
+ {
+ // Set up Configuration
+ IConfigurationRoot configuration = new ConfigurationBuilder()
+ .SetBasePath(Directory.GetCurrentDirectory())
+ .AddJsonFile("appsettings.json", optional: false)
+ .Build();
+
+ // Build service provider with DI
+ ServiceProvider serviceProvider = ConfigureServices(configuration);
+
+ // Get the required services
+ serviceProvider.GetRequiredService();
+ ILogger logger = serviceProvider.GetRequiredService>();
+ IAgentTaskService agentService = serviceProvider.GetRequiredService();
+
+ // Main application loop
+ bool exit = false;
+ while (!exit)
+ {
+ exit = await RunMainMenuAsync(agentService, logger);
+ }
+ }
+ catch (Exception ex)
+ {
+ AnsiConsole.MarkupLine($"[bold red]Error:[/] {ex.Message}");
+ AnsiConsole.WriteException(ex, ExceptionFormats.ShortenEverything);
+ }
+ }
+
+ private static ServiceProvider ConfigureServices(IConfiguration configuration)
+ {
+ ServiceCollection services = new();
+
+ // Add logging
+ services.AddLogging(builder =>
+ {
+ builder.AddConsole();
+ builder.SetMinimumLevel(LogLevel.Information);
+ });
+
+ // Add HttpClient for API Client
+ services.AddHttpClient(client =>
+ {
+ string baseUrl = configuration["ApiSettings:BaseUrl"] ?? throw new InvalidOperationException("Base URL not configured");
+ string apiKey = configuration["ApiSettings:ApiKey"] ?? throw new InvalidOperationException("API Key not configured");
+
+ client.BaseAddress = new Uri(baseUrl);
+ client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
+
+ if (int.TryParse(configuration["ApiSettings:DefaultTimeout"], out int timeout))
+ {
+ client.Timeout = TimeSpan.FromSeconds(timeout);
+ }
+ });
+
+ // Register the agent task service
+ services.AddScoped();
+
+ return services.BuildServiceProvider();
+ }
+
+ private static async Task RunMainMenuAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.Clear();
+ AnsiConsole.Write(new FigletText("Agent Tasks API").Centered().Color(Color.Blue));
+ AnsiConsole.WriteLine();
+
+ string choice = AnsiConsole.Prompt(
+ new SelectionPrompt()
+ .Title("What would you like to do?")
+ .PageSize(10)
+ .AddChoices(new[]
+ {
+ "Create a New Task",
+ "List All Tasks",
+ "Get Task Details",
+ "List Task Steps",
+ "Execute Task Step",
+ "Get Step Details",
+ "List Task Artifacts",
+ "Upload Artifact",
+ "Download Artifact",
+ "Exit"
+ }));
+
+ switch (choice)
+ {
+ case "Create a New Task":
+ await CreateNewTaskAsync(agentService, logger);
+ break;
+ case "List All Tasks":
+ await ListAllTasksAsync(agentService, logger);
+ break;
+ case "Get Task Details":
+ await GetTaskDetailsAsync(agentService, logger);
+ break;
+ case "List Task Steps":
+ await ListTaskStepsAsync(agentService, logger);
+ break;
+ case "Execute Task Step":
+ await ExecuteTaskStepAsync(agentService, logger);
+ break;
+ case "Get Step Details":
+ await GetStepDetailsAsync(agentService, logger);
+ break;
+ case "List Task Artifacts":
+ await ListTaskArtifactsAsync(agentService, logger);
+ break;
+ case "Upload Artifact":
+ await UploadArtifactAsync(agentService, logger);
+ break;
+ case "Download Artifact":
+ await DownloadArtifactAsync(agentService, logger);
+ break;
+ case "Exit":
+ return true;
+ }
+
+ // Wait for user to press a key before returning to the menu
+ AnsiConsole.WriteLine();
+ AnsiConsole.Markup("[dim]Press any key to continue...[/]");
+ Console.ReadKey(true);
+ return false;
+ }
+
+ private static async Task CreateNewTaskAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]Create a New Task[/]");
+ AnsiConsole.WriteLine();
+
+ string taskInput = AnsiConsole.Ask("Enter task input text:");
+
+ try
+ {
+ logger.LogInformation("Creating new task with input: {TaskInput}", taskInput);
+ AgentTask task = await agentService.CreateTaskAsync(taskInput);
+
+ // Display the result
+ AnsiConsole.MarkupLine("[green]Task created successfully![/]");
+ DisplayTask(task);
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to create task");
+ AnsiConsole.MarkupLine($"[red]Error creating task: {ex.Message}[/]");
+ }
+ }
+
+ private static async Task ListAllTasksAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]List All Tasks[/]");
+ AnsiConsole.WriteLine();
+
+ int pageSize = AnsiConsole.Ask("Page size:", 10);
+ int currentPage = AnsiConsole.Ask("Page number:", 1);
+
+ try
+ {
+ logger.LogInformation("Listing tasks (page {Page}, size {Size})", currentPage, pageSize);
+ PaginatedData pagedTasks = await agentService.GetTasksAsync(currentPage, pageSize);
+
+ // Display the results
+ Table table = new Table()
+ .Border(TableBorder.Rounded)
+ .AddColumn("Task ID")
+ .AddColumn("Input")
+ .AddColumn("Status")
+ .AddColumn("Created At");
+
+ foreach (AgentTask task in pagedTasks.Data)
+ {
+ table.AddRow(
+ task.Id,
+ task.Input ?? "N/A",
+ task.Status ?? "N/A",
+ task.CreatedAt.ToString("g")
+ );
+ }
+
+ AnsiConsole.Write(table);
+ AnsiConsole.MarkupLine($"Page {pagedTasks.CurrentPage} of {pagedTasks.TotalPages} (Total: {pagedTasks.TotalCount} tasks)");
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to list tasks");
+ AnsiConsole.MarkupLine($"[red]Error listing tasks: {ex.Message}[/]");
+ }
+ }
+
+ private static async Task GetTaskDetailsAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]Get Task Details[/]");
+ AnsiConsole.WriteLine();
+
+ string taskId = AnsiConsole.Ask("Enter task ID:");
+
+ try
+ {
+ logger.LogInformation("Getting details for task {TaskId}", taskId);
+ AgentTask task = await agentService.GetTaskAsync(taskId);
+
+ // Display the result
+ DisplayTask(task);
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to get task details");
+ AnsiConsole.MarkupLine($"[red]Error getting task details: {ex.Message}[/]");
+ }
+ }
+
+ private static async Task ListTaskStepsAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]List Task Steps[/]");
+ AnsiConsole.WriteLine();
+
+ string taskId = AnsiConsole.Ask("Enter task ID:");
+ int pageSize = AnsiConsole.Ask("Page size:", 10);
+ int currentPage = AnsiConsole.Ask("Page number:", 1);
+
+ try
+ {
+ logger.LogInformation("Listing steps for task {TaskId}", taskId);
+ PaginatedData pagedSteps = await agentService.GetTaskStepsAsync(taskId, currentPage, pageSize);
+
+ // Display the results
+ Table table = new Table()
+ .Border(TableBorder.Rounded)
+ .AddColumn("Step ID")
+ .AddColumn("Status")
+ .AddColumn("Is Last")
+ .AddColumn("Created At");
+
+ foreach (AgentStep step in pagedSteps.Data)
+ {
+ table.AddRow(
+ step.Id,
+ step.Status,
+ step.IsLast ? "Yes" : "No",
+ step.CreatedAt.ToString("g")
+ );
+ }
+
+ AnsiConsole.Write(table);
+ AnsiConsole.MarkupLine($"Page {pagedSteps.CurrentPage} of {pagedSteps.TotalPages} (Total: {pagedSteps.TotalCount} steps)");
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to list task steps");
+ AnsiConsole.MarkupLine($"[red]Error listing task steps: {ex.Message}[/]");
+ }
+ }
+
+ private static async Task ExecuteTaskStepAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]Execute Task Step[/]");
+ AnsiConsole.WriteLine();
+
+ string taskId = AnsiConsole.Ask("Enter task ID:");
+ string input = AnsiConsole.Ask("Enter step input:");
+
+ try
+ {
+ logger.LogInformation("Executing step for task {TaskId}", taskId);
+ AgentStep step = await agentService.ExecuteTaskStepAsync(taskId, input);
+
+ // Display the result
+ AnsiConsole.MarkupLine("[green]Step executed successfully![/]");
+ DisplayStep(step);
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to execute task step");
+ AnsiConsole.MarkupLine($"[red]Error executing task step: {ex.Message}[/]");
+ }
+ }
+
+ private static async Task GetStepDetailsAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]Get Step Details[/]");
+ AnsiConsole.WriteLine();
+
+ string taskId = AnsiConsole.Ask("Enter task ID:");
+ string stepId = AnsiConsole.Ask("Enter step ID:");
+
+ try
+ {
+ logger.LogInformation("Getting details for step {StepId} in task {TaskId}", stepId, taskId);
+ AgentStep step = await agentService.GetTaskStepAsync(taskId, stepId);
+
+ // Display the result
+ DisplayStep(step);
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to get step details");
+ AnsiConsole.MarkupLine($"[red]Error getting step details: {ex.Message}[/]");
+ }
+ }
+
+ private static async Task ListTaskArtifactsAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]List Task Artifacts[/]");
+ AnsiConsole.WriteLine();
+
+ string taskId = AnsiConsole.Ask("Enter task ID:");
+ int pageSize = AnsiConsole.Ask("Page size:", 10);
+ int currentPage = AnsiConsole.Ask("Page number:", 1);
+
+ try
+ {
+ logger.LogInformation("Listing artifacts for task {TaskId}", taskId);
+ PaginatedData pagedArtifacts = await agentService.GetTaskArtifactsAsync(taskId, currentPage, pageSize);
+
+ // Display the results
+ Table table = new Table()
+ .Border(TableBorder.Rounded)
+ .AddColumn("Artifact ID")
+ .AddColumn("Filename")
+ .AddColumn("Path")
+ .AddColumn("Agent Created")
+ .AddColumn("Created At");
+
+ foreach (AgentArtifact artifact in pagedArtifacts.Data)
+ {
+ table.AddRow(
+ artifact.Id,
+ artifact.FileName,
+ artifact.RelativePath ?? "-",
+ artifact.AgentCreated ? "Yes" : "No",
+ artifact.CreatedAt.ToString("g")
+ );
+ }
+
+ AnsiConsole.Write(table);
+ AnsiConsole.MarkupLine($"Page {pagedArtifacts.CurrentPage} of {pagedArtifacts.TotalPages} (Total: {pagedArtifacts.TotalCount} artifacts)");
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to list task artifacts");
+ AnsiConsole.MarkupLine($"[red]Error listing task artifacts: {ex.Message}[/]");
+ }
+ }
+
+ private static async Task UploadArtifactAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]Upload Artifact[/]");
+ AnsiConsole.WriteLine();
+
+ string taskId = AnsiConsole.Ask("Enter task ID:");
+ string filePath = AnsiConsole.Ask("Enter file path:");
+ string relativePath = AnsiConsole.Ask("Enter relative path in workspace:");
+
+ if (!File.Exists(filePath))
+ {
+ AnsiConsole.MarkupLine("[red]File not found![/]");
+ return;
+ }
+
+ try
+ {
+ logger.LogInformation("Uploading artifact for task {TaskId}", taskId);
+
+ AgentArtifact artifact = await agentService.UploadArtifactAsync(taskId, filePath, relativePath);
+
+ // Display the result
+ AnsiConsole.MarkupLine("[green]Artifact uploaded successfully![/]");
+ DisplayArtifact(artifact);
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to upload artifact");
+ AnsiConsole.MarkupLine($"[red]Error uploading artifact: {ex.Message}[/]");
+ }
+ }
+
+ private static async Task DownloadArtifactAsync(IAgentTaskService agentService, ILogger logger)
+ {
+ AnsiConsole.MarkupLine("[bold]Download Artifact[/]");
+ AnsiConsole.WriteLine();
+
+ string taskId = AnsiConsole.Ask("Enter task ID:");
+ string artifactId = AnsiConsole.Ask("Enter artifact ID:");
+ string outputPath = AnsiConsole.Ask("Enter download location:");
+
+ try
+ {
+ // Ensure directory exists
+ Directory.CreateDirectory(Path.GetDirectoryName(outputPath) ?? ".");
+
+ logger.LogInformation("Downloading artifact {ArtifactId} from task {TaskId}", artifactId, taskId);
+
+ // Download the file
+ await agentService.DownloadArtifactAsync(taskId, artifactId, outputPath);
+
+ // Display the result
+ AnsiConsole.MarkupLine("[green]Artifact downloaded successfully![/]");
+ AnsiConsole.MarkupLine($"Saved to: {outputPath}");
+ }
+ catch (ApiException ex)
+ {
+ logger.LogError(ex, "Failed to download artifact");
+ AnsiConsole.MarkupLine($"[red]Error downloading artifact: {ex.Message}[/]");
+ }
+ }
+
+ private static void DisplayTask(AgentTask task)
+ {
+ Panel panel = new Panel(
+ Markup.Escape($"Task ID: {task.Id}\n" +
+ $"Input: {task.Input ?? "N/A"}\n" +
+ $"Status: {task.Status ?? "N/A"}\n" +
+ $"Created At: {task.CreatedAt}\n" +
+ $"Artifacts: {task.Artifacts.Count}")
+ )
+ .Header("Task Details")
+ .Expand();
+
+ AnsiConsole.Write(panel);
+
+ if (task.Artifacts.Count > 0)
+ {
+ AnsiConsole.MarkupLine("\n[bold]Task Artifacts:[/]");
+ Table artifactsTable = new Table()
+ .Border(TableBorder.Rounded)
+ .AddColumn("Artifact ID")
+ .AddColumn("Filename")
+ .AddColumn("Path");
+
+ foreach (AgentArtifact artifact in task.Artifacts)
+ {
+ artifactsTable.AddRow(
+ artifact.Id,
+ artifact.FileName,
+ artifact.RelativePath ?? "-"
+ );
+ }
+
+ AnsiConsole.Write(artifactsTable);
+ }
+ }
+
+ private static void DisplayStep(AgentStep step)
+ {
+ Panel panel = new Panel(
+ Markup.Escape($"Step ID: {step.Id}\n" +
+ $"Task ID: {step.TaskId}\n" +
+ $"Status: {step.Status}\n" +
+ $"Is Last: {(step.IsLast ? "Yes" : "No")}\n" +
+ $"Created At: {step.CreatedAt}\n" +
+ $"Executed At: {step.ExecutedAt ?? DateTime.MinValue}\n" +
+ $"Input: {step.Input ?? "N/A"}\n" +
+ $"Output: {step.Output ?? "N/A"}")
+ )
+ .Header("Step Details")
+ .Expand();
+
+ AnsiConsole.Write(panel);
+
+ if (step.Artifacts.Count > 0)
+ {
+ AnsiConsole.MarkupLine("\n[bold]Step Artifacts:[/]");
+ Table artifactsTable = new Table()
+ .Border(TableBorder.Rounded)
+ .AddColumn("Artifact ID")
+ .AddColumn("Filename")
+ .AddColumn("Path");
+
+ foreach (AgentArtifact artifact in step.Artifacts)
+ {
+ artifactsTable.AddRow(
+ artifact.Id,
+ artifact.FileName,
+ artifact.RelativePath ?? "-"
+ );
+ }
+
+ AnsiConsole.Write(artifactsTable);
+ }
+ }
+
+ private static void DisplayArtifact(AgentArtifact artifact)
+ {
+ Panel panel = new Panel(
+ Markup.Escape($"Artifact ID: {artifact.Id}\n" +
+ $"Filename: {artifact.FileName}\n" +
+ $"Path: {artifact.RelativePath ?? "N/A"}\n" +
+ $"Size: {artifact.Size / 1024.0:F2} KB\n" +
+ $"Agent Created: {(artifact.AgentCreated ? "Yes" : "No")}\n" +
+ $"Created At: {artifact.CreatedAt}")
+ )
+ .Header("Artifact Details")
+ .Expand();
+
+ AnsiConsole.Write(panel);
+ }
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Examples/ConsoleApplication/README.md b/packages/sdk/C#/Examples/ConsoleApplication/README.md
new file mode 100644
index 00000000..8cd70368
--- /dev/null
+++ b/packages/sdk/C#/Examples/ConsoleApplication/README.md
@@ -0,0 +1,61 @@
+# Example Console Application
+
+This console application demonstrates how to use the generated Agent Protocol API client SDK to interact with the Agent Tasks API. The application provides a user-friendly command-line interface for performing various operations with agent tasks, steps, and artifacts.
+
+## Features
+
+- Create new agent tasks
+- List all existing tasks with pagination
+- View detailed information about a specific task
+- List steps for a task with pagination
+- Execute task steps
+- View detailed information about a specific step
+- List artifacts for a task with pagination
+- Upload new artifacts to a task
+- Download existing artifacts
+
+## Project Structure
+
+```
+ConsoleApplication/
+├── Program.cs # Main application entry point and UI
+├── Models/
+│ └── AgentTaskModels.cs # Domain models for tasks, steps, and artifacts
+├── Services/
+│ └── AgentTaskService.cs # Service layer for API interactions
+├── appsettings.json # Application configuration
+└── ConsoleApplication.csproj # Project file with dependencies
+```
+
+## Prerequisites
+
+- .NET 8.0 SDK
+- Access to an Agent Protocol compatible API
+- The generated API client SDK (referenced in the project)
+
+## Setup
+
+1. Clone this repository
+2. Update the `appsettings.json` file with your API credentials:
+
+ ```json
+ {
+ "ApiSettings": {
+ "BaseUrl": "https://api.example.com",
+ "ApiKey": "your-api-key-here",
+ "DefaultTimeout": 30
+ }
+ }
+ ```
+
+3. Build the project:
+
+ ```
+ dotnet build
+ ```
+
+## Running the Application
+
+```bash
+dotnet run
+```
diff --git a/packages/sdk/C#/Examples/ConsoleApplication/appsettings.json b/packages/sdk/C#/Examples/ConsoleApplication/appsettings.json
new file mode 100644
index 00000000..4bc146f7
--- /dev/null
+++ b/packages/sdk/C#/Examples/ConsoleApplication/appsettings.json
@@ -0,0 +1,7 @@
+{
+ "ApiSettings": {
+ "BaseUrl": "https://api.example.com",
+ "ApiKey": "your-api-key-here",
+ "DefaultTimeout": 30
+ }
+}
diff --git a/packages/sdk/C#/Generator/Common/Configs/LoggingConfiguration.cs b/packages/sdk/C#/Generator/Common/Configs/LoggingConfiguration.cs
new file mode 100644
index 00000000..1d9e151a
--- /dev/null
+++ b/packages/sdk/C#/Generator/Common/Configs/LoggingConfiguration.cs
@@ -0,0 +1,20 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+
+namespace Generator.Common.Configs;
+
+public static class LoggingConfiguration
+{
+ public static IServiceCollection ConfigureLogging(this IServiceCollection services, LogLevel minimumLevel = LogLevel.Information)
+ {
+ services.AddLogging(builder =>
+ {
+ builder.ClearProviders();
+ builder.AddConsole();
+
+ builder.SetMinimumLevel(minimumLevel);
+ });
+
+ return services;
+ }
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Generator/Common/Extensions/ServiceCollectionExtensions.cs b/packages/sdk/C#/Generator/Common/Extensions/ServiceCollectionExtensions.cs
new file mode 100644
index 00000000..b1a503ae
--- /dev/null
+++ b/packages/sdk/C#/Generator/Common/Extensions/ServiceCollectionExtensions.cs
@@ -0,0 +1,17 @@
+using Generator.Common.Configs;
+using Generator.Services;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Generator.Common.Extensions;
+
+public static class ServiceCollectionExtensions
+{
+ public static IServiceCollection AddApplicationServices(this IServiceCollection services)
+ {
+ services.ConfigureLogging();
+
+ services.AddScoped();
+
+ return services;
+ }
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Generator/Generator.csproj b/packages/sdk/C#/Generator/Generator.csproj
new file mode 100644
index 00000000..bfa86ab5
--- /dev/null
+++ b/packages/sdk/C#/Generator/Generator.csproj
@@ -0,0 +1,26 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+ latest
+ true
+ openapi-generator | agent protocol
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/sdk/C#/Generator/Options.cs b/packages/sdk/C#/Generator/Options.cs
new file mode 100644
index 00000000..f0b79cc7
--- /dev/null
+++ b/packages/sdk/C#/Generator/Options.cs
@@ -0,0 +1,15 @@
+using CommandLine;
+
+namespace Generator;
+
+public class Options
+{
+ [Option('i', "input", Required = true, HelpText = "Input OpenAPI JSON file path.")]
+ public string InputFilePath { get; set; } = string.Empty;
+
+ [Option('o', "output", Required = false, HelpText = "Output directory for generated C# client.")]
+ public string? OutputDirectory { get; set; }
+
+ [Option('n', "namespace", Required = false, Default = "GeneratedApiClient", HelpText = "Namespace for the generated client.")]
+ public string Namespace { get; set; } = "GeneratedApiClient";
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Generator/Program.cs b/packages/sdk/C#/Generator/Program.cs
new file mode 100644
index 00000000..2593ebca
--- /dev/null
+++ b/packages/sdk/C#/Generator/Program.cs
@@ -0,0 +1,69 @@
+using CommandLine;
+using Generator.Common.Extensions;
+using Generator.Services;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+
+namespace Generator;
+// Command line options class
+
+public class Program
+{
+ public static async Task Main(string[] args)
+ {
+ // Setup dependency injection
+ IServiceProvider serviceProvider = ConfigureServices();
+
+ return await Parser.Default.ParseArguments(args)
+ .MapResult(
+ async (Options opts) => await RunWithOptionsAsync(opts, serviceProvider),
+ errs => Task.FromResult(1)
+ );
+ }
+
+ private static IServiceProvider ConfigureServices()
+ {
+ ServiceCollection services = new();
+
+ // Configure all services using the extension method
+ services.AddApplicationServices();
+
+ return services.BuildServiceProvider();
+ }
+
+ private static async Task RunWithOptionsAsync(Options options, IServiceProvider serviceProvider)
+ {
+ // Get logger
+ ILogger? logger = serviceProvider.GetService(typeof(ILogger)) as ILogger;
+ logger?.LogInformation("Starting OpenAPI Client Generator");
+
+ try
+ {
+ // Determine output directory
+ string outputDir = options.OutputDirectory ?? System.IO.Path.Combine(
+ System.IO.Directory.GetCurrentDirectory(), "Generated");
+
+ // Get the generator service
+ IApiClientGeneratorService? generatorService = serviceProvider.GetService(typeof(IApiClientGeneratorService)) as IApiClientGeneratorService;
+ if (generatorService == null)
+ {
+ logger?.LogError("Failed to resolve ApiClientGeneratorService");
+ return 1;
+ }
+
+ // Generate the client
+ bool result = await generatorService.GenerateClientAsync(
+ options.InputFilePath,
+ outputDir,
+ options.Namespace
+ );
+
+ return result ? 0 : 1;
+ }
+ catch (Exception ex)
+ {
+ logger?.LogError(ex, "Unhandled exception: {Message}", ex.Message);
+ return 1;
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Generator/Services/ApiClientGeneratorService.cs b/packages/sdk/C#/Generator/Services/ApiClientGeneratorService.cs
new file mode 100644
index 00000000..6c330b38
--- /dev/null
+++ b/packages/sdk/C#/Generator/Services/ApiClientGeneratorService.cs
@@ -0,0 +1,58 @@
+using Microsoft.Extensions.Logging;
+using NSwag;
+using NSwag.CodeGeneration.CSharp;
+
+namespace Generator.Services;
+
+public class ApiClientGeneratorService(ILogger logger) : IApiClientGeneratorService
+{
+ private readonly ILogger _logger = logger ?? throw new ArgumentNullException(nameof(logger));
+
+ public async Task GenerateClientAsync(string inputFilePath, string outputDirectory, string namespaceName)
+ {
+ try
+ {
+ _logger.LogInformation("Loading OpenAPI specification from: {FilePath}", inputFilePath);
+
+ if (!File.Exists(inputFilePath))
+ {
+ _logger.LogError("Input file '{FilePath}' does not exist", inputFilePath);
+ return false;
+ }
+
+ Directory.CreateDirectory(outputDirectory);
+
+ _logger.LogDebug("Parsing OpenAPI document");
+ OpenApiDocument? document = await OpenApiDocument.FromFileAsync(inputFilePath);
+
+ CSharpClientGeneratorSettings settings = new()
+ {
+ ClassName = "ApiClient",
+ CSharpGeneratorSettings =
+ {
+ Namespace = namespaceName,
+ GenerateNullableReferenceTypes = true
+ },
+ GenerateDtoTypes = true,
+ GenerateClientInterfaces = true,
+ GenerateOptionalParameters = true,
+ UseBaseUrl = false
+ };
+
+ _logger.LogInformation("Generating C# client code with namespace: {Namespace}", namespaceName);
+ CSharpClientGenerator generator = new(document, settings);
+ string? code = generator.GenerateFile();
+
+ string outputFile = Path.Combine(outputDirectory, "ApiClient.cs");
+ await File.WriteAllTextAsync(outputFile, code);
+
+ _logger.LogInformation("Client successfully generated at: {OutputPath}", outputFile);
+ return true;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error generating client: {ErrorMessage}", ex.Message);
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Generator/Services/IApiClientGeneratorService.cs b/packages/sdk/C#/Generator/Services/IApiClientGeneratorService.cs
new file mode 100644
index 00000000..245f83d5
--- /dev/null
+++ b/packages/sdk/C#/Generator/Services/IApiClientGeneratorService.cs
@@ -0,0 +1,6 @@
+namespace Generator.Services;
+
+public interface IApiClientGeneratorService
+{
+ Task GenerateClientAsync(string inputFilePath, string outputDirectory, string namespaceName);
+}
\ No newline at end of file
diff --git a/packages/sdk/C#/Library/ApiClient.cs b/packages/sdk/C#/Library/ApiClient.cs
new file mode 100644
index 00000000..40745781
--- /dev/null
+++ b/packages/sdk/C#/Library/ApiClient.cs
@@ -0,0 +1,3343 @@
+//----------------------
+//
+// Generated using the NSwag toolchain v14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
+//
+//----------------------
+
+#nullable enable
+
+#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended."
+#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword."
+#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?'
+#pragma warning disable 612 // Disable "CS0612 '...' is obsolete"
+#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ...
+#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..."
+#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'"
+#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant"
+#pragma warning disable 8603 // Disable "CS8603 Possible null reference return"
+#pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter"
+#pragma warning disable 8625 // Disable "CS8625 Cannot convert null literal to non-nullable reference type"
+
+namespace AnotherAgentProtocolLibrary
+{
+ using System = global::System;
+
+ [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
+ public partial interface IApiClient
+ {
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Creates a task for the agent.
+ ///
+ /// A new agent task was successfully created.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task CreateAgentTaskAsync(Body? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// List all tasks that have been created for the agent.
+ ///
+ /// Page number
+ /// Number of items per page
+ /// Returned list of agent's tasks.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task ListAgentTasksAsync(int? current_page = null, int? page_size = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get details about a specified agent task.
+ ///
+ /// ID of the task
+ /// Returned details about an agent task.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task GetAgentTaskAsync(string task_id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// List all steps for the specified task.
+ ///
+ /// ID of the task.
+ /// Page number
+ /// Number of items per page
+ /// Returned list of agent's steps for the specified task.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task ListAgentTaskStepsAsync(string task_id, int? current_page = null, int? page_size = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Execute a step in the specified agent task.
+ ///
+ /// ID of the task
+ /// Executed step for the agent task.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task ExecuteAgentTaskStepAsync(string task_id, Body2? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Get details about a specified task step.
+ ///
+ /// ID of the task
+ /// ID of the step
+ /// Returned details about an agent task step.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task GetAgentTaskStepAsync(string task_id, string step_id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// List all artifacts that have been created for the given task.
+ ///
+ /// ID of the task
+ /// Page number
+ /// Number of items per page
+ /// Returned the list of artifacts for the task.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task ListAgentTaskArtifactsAsync(string task_id, int? current_page = null, int? page_size = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Upload an artifact for the specified task.
+ ///
+ /// ID of the task
+ /// File to upload.
+ /// Relative path of the artifact in the agent's workspace.
+ /// Returned the content of the artifact.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task UploadAgentTaskArtifactsAsync(string task_id, FileParameter file = null, string? relative_path = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Download a specified artifact.
+ ///
+ /// ID of the task
+ /// ID of the artifact
+ /// Returned the content of the artifact.
+ /// A server side error occurred.
+ System.Threading.Tasks.Task DownloadAgentTaskArtifactAsync(string task_id, string artifact_id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ }
+
+ [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")]
+ public partial class ApiClient : IApiClient
+ {
+ #pragma warning disable 8618
+ private string _baseUrl;
+ #pragma warning restore 8618
+
+ private System.Net.Http.HttpClient _httpClient;
+ private static System.Lazy _settings = new System.Lazy(CreateSerializerSettings, true);
+
+ public ApiClient(System.Net.Http.HttpClient httpClient)
+ {
+ _httpClient = httpClient;
+ }
+
+ private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings()
+ {
+ var settings = new Newtonsoft.Json.JsonSerializerSettings();
+ UpdateJsonSerializerSettings(settings);
+ return settings;
+ }
+
+ protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } }
+
+ static partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings);
+
+ partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url);
+ partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
+ partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);
+
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ ///
+ /// Creates a task for the agent.
+ ///
+ /// A new agent task was successfully created.
+ /// A server side error occurred.
+ public virtual async System.Threading.Tasks.Task CreateAgentTaskAsync(Body? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
+ {
+ var client_ = _httpClient;
+ var disposeClient_ = false;
+ try
+ {
+ using (var request_ = new System.Net.Http.HttpRequestMessage())
+ {
+ var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value);
+ var content_ = new System.Net.Http.StringContent(json_);
+ content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
+ request_.Content = content_;
+ request_.Method = new System.Net.Http.HttpMethod("POST");
+ request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));
+
+ var urlBuilder_ = new System.Text.StringBuilder();
+
+ // Operation Path: "ap/v1/agent/tasks"
+ urlBuilder_.Append("ap/v1/agent/tasks");
+
+ PrepareRequest(client_, request_, urlBuilder_);
+
+ var url_ = urlBuilder_.ToString();
+ request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
+
+ PrepareRequest(client_, request_, url_);
+
+ var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
+ var disposeResponse_ = true;
+ try
+ {
+ var headers_ = new System.Collections.Generic.Dictionary>();
+ foreach (var item_ in response_.Headers)
+ headers_[item_.Key] = item_.Value;
+ if (response_.Content != null && response_.Content.Headers != null)
+ {
+ foreach (var item_ in response_.Content.Headers)
+ headers_[item_.Key] = item_.Value;
+ }
+
+ ProcessResponse(client_, response_);
+
+ var status_ = (int)response_.StatusCode;
+ if (status_ == 200)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false);
+ if (objectResponse_.Object == null)
+ {
+ throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
+ }
+ return objectResponse_.Object;
+ }
+ else
+ if (status_ == 422)
+ {
+ var objectResponse_ = await ReadObjectResponseAsync