diff --git a/src/libs/Greptile/Generated/Greptile.AutoSDKHttpResponse.g.cs b/src/libs/Greptile/Generated/Greptile.AutoSDKHttpResponse.g.cs new file mode 100644 index 0000000..365c0e9 --- /dev/null +++ b/src/libs/Greptile/Generated/Greptile.AutoSDKHttpResponse.g.cs @@ -0,0 +1,121 @@ + +#nullable enable + +namespace Greptile +{ + /// + /// Represents a successful HTTP response with status code and headers. + /// + public partial class AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri) + { + StatusCode = statusCode; + Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers)); + RequestUri = requestUri; + } + + /// + /// Gets the HTTP status code. + /// + public global::System.Net.HttpStatusCode StatusCode { get; } + /// + /// Gets the response headers. + /// + public global::System.Collections.Generic.Dictionary> Headers { get; } + /// + /// Gets the final request URI associated with the response. + /// + public global::System.Uri? RequestUri { get; } + + internal static global::System.Collections.Generic.Dictionary> CreateHeaders( + global::System.Net.Http.HttpResponseMessage response) + { + response = response ?? throw new global::System.ArgumentNullException(nameof(response)); + + var headers = global::System.Linq.Enumerable.ToDictionary( + response.Headers, + static header => header.Key, + static header => (global::System.Collections.Generic.IEnumerable)global::System.Linq.Enumerable.ToArray(header.Value), + global::System.StringComparer.OrdinalIgnoreCase); + + if (response.Content?.Headers == null) + { + return headers; + } + + foreach (var header in response.Content.Headers) + { + if (headers.TryGetValue(header.Key, out var existingValues)) + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray( + global::System.Linq.Enumerable.Concat(existingValues, header.Value)); + } + else + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value); + } + } + + return headers; + } + } + + /// + /// Represents a successful HTTP response with status code, headers, and body. + /// + public partial class AutoSDKHttpResponse : AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + T body) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null, + body: body) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri, + T body) + : base(statusCode, headers, requestUri) + { + Body = body; + } + + /// + /// Gets the response body. + /// + public T Body { get; } + } +} \ No newline at end of file diff --git a/src/libs/Greptile/Generated/Greptile.GreptileClient.GetRepositoryInfo.g.cs b/src/libs/Greptile/Generated/Greptile.GreptileClient.GetRepositoryInfo.g.cs index 6619fd5..4e4514e 100644 --- a/src/libs/Greptile/Generated/Greptile.GreptileClient.GetRepositoryInfo.g.cs +++ b/src/libs/Greptile/Generated/Greptile.GreptileClient.GetRepositoryInfo.g.cs @@ -53,6 +53,27 @@ partial void ProcessGetRepositoryInfoResponseContent( string repositoryId, global::Greptile.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetRepositoryInfoAsResponseAsync( + repositoryId: repositoryId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get repository information
+ /// Retrieves the current status and information about a repository's index. The repositoryId should be URL-encoded in the format remote:branch:owner/repository. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetRepositoryInfoAsResponseAsync( + string repositoryId, + global::Greptile.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -82,6 +103,7 @@ partial void ProcessGetRepositoryInfoResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Greptile.PathBuilder( path: $"/repositories/{repositoryId}", baseUri: HttpClient.BaseAddress); @@ -155,6 +177,8 @@ partial void ProcessGetRepositoryInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -165,6 +189,11 @@ partial void ProcessGetRepositoryInfoResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Greptile.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Greptile.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -182,6 +211,8 @@ partial void ProcessGetRepositoryInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -191,8 +222,7 @@ partial void ProcessGetRepositoryInfoResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Greptile.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -201,6 +231,11 @@ partial void ProcessGetRepositoryInfoResponseContent( __attempt < __maxAttempts && global::Greptile.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Greptile.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Greptile.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Greptile.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -217,14 +252,15 @@ partial void ProcessGetRepositoryInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Greptile.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -264,6 +300,8 @@ partial void ProcessGetRepositoryInfoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -284,6 +322,8 @@ partial void ProcessGetRepositoryInfoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Repository not found @@ -384,9 +424,13 @@ partial void ProcessGetRepositoryInfoResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Greptile.RepositoryInfo.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Greptile.RepositoryInfo.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Greptile.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Greptile.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -414,9 +458,13 @@ partial void ProcessGetRepositoryInfoResponseContent( #endif ).ConfigureAwait(false); - return - await global::Greptile.RepositoryInfo.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Greptile.RepositoryInfo.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Greptile.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Greptile.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Greptile/Generated/Greptile.GreptileClient.IndexRepository.g.cs b/src/libs/Greptile/Generated/Greptile.GreptileClient.IndexRepository.g.cs index ecc2de0..3c56f7f 100644 --- a/src/libs/Greptile/Generated/Greptile.GreptileClient.IndexRepository.g.cs +++ b/src/libs/Greptile/Generated/Greptile.GreptileClient.IndexRepository.g.cs @@ -51,6 +51,29 @@ partial void ProcessIndexRepositoryResponseContent( /// public async global::System.Threading.Tasks.Task IndexRepositoryAsync( + global::Greptile.IndexRepositoryRequest request, + global::Greptile.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await IndexRepositoryAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Index a repository
+ /// Initiates processing or reprocessing of a specified repository. The repository must be indexed before it can be queried or searched. Indexing may take some time for large repositories. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> IndexRepositoryAsResponseAsync( + global::Greptile.IndexRepositoryRequest request, global::Greptile.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessIndexRepositoryResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Greptile.PathBuilder( path: "/repositories", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessIndexRepositoryResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessIndexRepositoryResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Greptile.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Greptile.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessIndexRepositoryResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessIndexRepositoryResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Greptile.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessIndexRepositoryResponseContent( __attempt < __maxAttempts && global::Greptile.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Greptile.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Greptile.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Greptile.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessIndexRepositoryResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Greptile.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessIndexRepositoryResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessIndexRepositoryResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad request @@ -393,9 +435,13 @@ partial void ProcessIndexRepositoryResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Greptile.IndexRepositoryResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Greptile.IndexRepositoryResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Greptile.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Greptile.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -423,9 +469,13 @@ partial void ProcessIndexRepositoryResponseContent( #endif ).ConfigureAwait(false); - return - await global::Greptile.IndexRepositoryResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Greptile.IndexRepositoryResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Greptile.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Greptile.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Greptile/Generated/Greptile.GreptileClient.QueryCodebase.g.cs b/src/libs/Greptile/Generated/Greptile.GreptileClient.QueryCodebase.g.cs index 952ff5e..f3b5b9f 100644 --- a/src/libs/Greptile/Generated/Greptile.GreptileClient.QueryCodebase.g.cs +++ b/src/libs/Greptile/Generated/Greptile.GreptileClient.QueryCodebase.g.cs @@ -51,6 +51,29 @@ partial void ProcessQueryCodebaseResponseContent( /// public async global::System.Threading.Tasks.Task QueryCodebaseAsync( + global::Greptile.QueryRequest request, + global::Greptile.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await QueryCodebaseAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Query a codebase
+ /// Query repositories in natural language and get back an AI-generated answer along with a list of relevant source files, functions, and classes. The query must be formatted as a messages array following the OpenAI Chat format. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> QueryCodebaseAsResponseAsync( + global::Greptile.QueryRequest request, global::Greptile.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -81,10 +104,11 @@ partial void ProcessQueryCodebaseResponseContent( var __maxAttempts = global::Greptile.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Greptile.PathBuilder( path: "/query", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessQueryCodebaseResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessQueryCodebaseResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Greptile.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Greptile.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessQueryCodebaseResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessQueryCodebaseResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Greptile.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessQueryCodebaseResponseContent( __attempt < __maxAttempts && global::Greptile.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Greptile.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Greptile.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Greptile.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessQueryCodebaseResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Greptile.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessQueryCodebaseResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessQueryCodebaseResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad request @@ -393,9 +435,13 @@ partial void ProcessQueryCodebaseResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Greptile.QueryResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Greptile.QueryResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Greptile.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Greptile.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -423,9 +469,13 @@ partial void ProcessQueryCodebaseResponseContent( #endif ).ConfigureAwait(false); - return - await global::Greptile.QueryResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Greptile.QueryResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Greptile.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Greptile.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Greptile/Generated/Greptile.GreptileClient.SearchCodebase.g.cs b/src/libs/Greptile/Generated/Greptile.GreptileClient.SearchCodebase.g.cs index 94d9552..5d637b0 100644 --- a/src/libs/Greptile/Generated/Greptile.GreptileClient.SearchCodebase.g.cs +++ b/src/libs/Greptile/Generated/Greptile.GreptileClient.SearchCodebase.g.cs @@ -51,6 +51,29 @@ partial void ProcessSearchCodebaseResponseContent( /// public async global::System.Threading.Tasks.Task SearchCodebaseAsync( + global::Greptile.SearchRequest request, + global::Greptile.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await SearchCodebaseAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Search a codebase
+ /// Search repositories in natural language and get back a list of relevant code files, functions, and snippets. Similar to the query endpoint but without the AI-generated answer. Use this endpoint when you only need the source references. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> SearchCodebaseAsResponseAsync( + global::Greptile.SearchRequest request, global::Greptile.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessSearchCodebaseResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Greptile.PathBuilder( path: "/search", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessSearchCodebaseResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessSearchCodebaseResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Greptile.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Greptile.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessSearchCodebaseResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessSearchCodebaseResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Greptile.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessSearchCodebaseResponseContent( __attempt < __maxAttempts && global::Greptile.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Greptile.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Greptile.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Greptile.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessSearchCodebaseResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Greptile.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessSearchCodebaseResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessSearchCodebaseResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad request @@ -393,9 +435,13 @@ partial void ProcessSearchCodebaseResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Greptile.SearchResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Greptile.SearchResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Greptile.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Greptile.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -423,9 +469,13 @@ partial void ProcessSearchCodebaseResponseContent( #endif ).ConfigureAwait(false); - return - await global::Greptile.SearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Greptile.SearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Greptile.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Greptile.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Greptile/Generated/Greptile.GreptileClient.g.cs b/src/libs/Greptile/Generated/Greptile.GreptileClient.g.cs index d5572b7..c120635 100644 --- a/src/libs/Greptile/Generated/Greptile.GreptileClient.g.cs +++ b/src/libs/Greptile/Generated/Greptile.GreptileClient.g.cs @@ -73,10 +73,10 @@ public GreptileClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public GreptileClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Greptile.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Greptile.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Greptile/Generated/Greptile.IGreptileClient.GetRepositoryInfo.g.cs b/src/libs/Greptile/Generated/Greptile.IGreptileClient.GetRepositoryInfo.g.cs index 7fb3de2..555e5f7 100644 --- a/src/libs/Greptile/Generated/Greptile.IGreptileClient.GetRepositoryInfo.g.cs +++ b/src/libs/Greptile/Generated/Greptile.IGreptileClient.GetRepositoryInfo.g.cs @@ -16,5 +16,17 @@ public partial interface IGreptileClient string repositoryId, global::Greptile.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get repository information
+ /// Retrieves the current status and information about a repository's index. The repositoryId should be URL-encoded in the format remote:branch:owner/repository. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetRepositoryInfoAsResponseAsync( + string repositoryId, + global::Greptile.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Greptile/Generated/Greptile.IGreptileClient.IndexRepository.g.cs b/src/libs/Greptile/Generated/Greptile.IGreptileClient.IndexRepository.g.cs index 58fc6e6..1e6e7c5 100644 --- a/src/libs/Greptile/Generated/Greptile.IGreptileClient.IndexRepository.g.cs +++ b/src/libs/Greptile/Generated/Greptile.IGreptileClient.IndexRepository.g.cs @@ -21,6 +21,19 @@ public partial interface IGreptileClient /// Index a repository
/// Initiates processing or reprocessing of a specified repository. The repository must be indexed before it can be queried or searched. Indexing may take some time for large repositories. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> IndexRepositoryAsResponseAsync( + + global::Greptile.IndexRepositoryRequest request, + global::Greptile.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Index a repository
+ /// Initiates processing or reprocessing of a specified repository. The repository must be indexed before it can be queried or searched. Indexing may take some time for large repositories. + ///
/// /// The remote service hosting the repository
/// Example: github diff --git a/src/libs/Greptile/Generated/Greptile.IGreptileClient.QueryCodebase.g.cs b/src/libs/Greptile/Generated/Greptile.IGreptileClient.QueryCodebase.g.cs index 6607128..61d9f33 100644 --- a/src/libs/Greptile/Generated/Greptile.IGreptileClient.QueryCodebase.g.cs +++ b/src/libs/Greptile/Generated/Greptile.IGreptileClient.QueryCodebase.g.cs @@ -21,6 +21,19 @@ public partial interface IGreptileClient /// Query a codebase
/// Query repositories in natural language and get back an AI-generated answer along with a list of relevant source files, functions, and classes. The query must be formatted as a messages array following the OpenAI Chat format. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> QueryCodebaseAsResponseAsync( + + global::Greptile.QueryRequest request, + global::Greptile.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Query a codebase
+ /// Query repositories in natural language and get back an AI-generated answer along with a list of relevant source files, functions, and classes. The query must be formatted as a messages array following the OpenAI Chat format. + ///
/// /// The query messages in OpenAI Chat format. Can be a single message or a conversation history for multi-turn queries. /// diff --git a/src/libs/Greptile/Generated/Greptile.IGreptileClient.SearchCodebase.g.cs b/src/libs/Greptile/Generated/Greptile.IGreptileClient.SearchCodebase.g.cs index 37ded7e..cf0fb5d 100644 --- a/src/libs/Greptile/Generated/Greptile.IGreptileClient.SearchCodebase.g.cs +++ b/src/libs/Greptile/Generated/Greptile.IGreptileClient.SearchCodebase.g.cs @@ -21,6 +21,19 @@ public partial interface IGreptileClient /// Search a codebase
/// Search repositories in natural language and get back a list of relevant code files, functions, and snippets. Similar to the query endpoint but without the AI-generated answer. Use this endpoint when you only need the source references. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> SearchCodebaseAsResponseAsync( + + global::Greptile.SearchRequest request, + global::Greptile.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Search a codebase
+ /// Search repositories in natural language and get back a list of relevant code files, functions, and snippets. Similar to the query endpoint but without the AI-generated answer. Use this endpoint when you only need the source references. + ///
/// /// The search query formatted as a messages array /// diff --git a/src/libs/Greptile/Generated/Greptile.OptionsSupport.g.cs b/src/libs/Greptile/Generated/Greptile.OptionsSupport.g.cs index 0f407d2..c603ee7 100644 --- a/src/libs/Greptile/Generated/Greptile.OptionsSupport.g.cs +++ b/src/libs/Greptile/Generated/Greptile.OptionsSupport.g.cs @@ -101,9 +101,45 @@ public sealed class AutoSDKRetryOptions public int MaxAttempts { get; set; } = 1; /// - /// Optional fixed delay between retry attempts. + /// Optional fixed delay between retry attempts. When set, this takes precedence over exponential backoff. /// public global::System.TimeSpan? Delay { get; set; } + + /// + /// Initial exponential backoff delay used when is not set. + /// + public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1); + + /// + /// Maximum retry delay after applying retry headers, backoff, and jitter. + /// + public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30); + + /// + /// Multiplier applied to exponential backoff after each failed attempt. + /// Values below 1 are normalized to 1. + /// + public double BackoffMultiplier { get; set; } = 2D; + + /// + /// Randomizes computed backoff by plus or minus this ratio. Values are clamped to 0..1. + /// + public double JitterRatio { get; set; } = 0.2D; + + /// + /// Whether Retry-After response headers should control retry delay when present. + /// + public bool UseRetryAfterHeader { get; set; } = true; + + /// + /// Whether a rate-limit reset response header should control retry delay when present. + /// + public bool UseRateLimitResetHeader { get; set; } + + /// + /// Optional provider-specific rate-limit reset header name. Values may be Unix seconds or an HTTP date. + /// + public string? RateLimitResetHeaderName { get; set; } = "X-RateLimit-Reset"; } @@ -231,6 +267,16 @@ public sealed class AutoSDKHookContext /// public bool WillRetry { get; set; } + /// + /// The computed retry delay when is true. + /// + public global::System.TimeSpan? RetryDelay { get; set; } + + /// + /// A short retry reason such as exception or status:429. + /// + public string RetryReason { get; set; } = string.Empty; + /// /// The effective cancellation token for the current request attempt. /// @@ -254,6 +300,8 @@ internal static class AutoSDKRequestOptionsSupport int attempt, int maxAttempts, bool willRetry, + global::System.TimeSpan? retryDelay, + string retryReason, global::System.Threading.CancellationToken cancellationToken) { return new global::Greptile.AutoSDKHookContext @@ -271,6 +319,8 @@ internal static class AutoSDKRequestOptionsSupport Attempt = attempt, MaxAttempts = maxAttempts, WillRetry = willRetry, + RetryDelay = retryDelay, + RetryReason = retryReason ?? string.Empty, CancellationToken = cancellationToken, }; } @@ -338,19 +388,188 @@ internal static int GetMaxAttempts( return maxAttempts < 1 ? 1 : maxAttempts; } - internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + internal static global::System.TimeSpan GetRetryDelay( global::Greptile.AutoSDKClientOptions clientOptions, global::Greptile.AutoSDKRequestOptions? requestOptions, + global::System.Net.Http.HttpResponseMessage? response, + int attempt) + { + var retryOptions = requestOptions?.Retry ?? clientOptions.Retry ?? new global::Greptile.AutoSDKRetryOptions(); + + if (retryOptions.UseRetryAfterHeader && + TryGetRetryAfterDelay(response, out var retryAfterDelay)) + { + return ClampRetryDelay(retryAfterDelay, retryOptions); + } + + if (retryOptions.UseRateLimitResetHeader && + TryGetRateLimitResetDelay(response, retryOptions.RateLimitResetHeaderName, out var rateLimitResetDelay)) + { + return ClampRetryDelay(rateLimitResetDelay, retryOptions); + } + + if (retryOptions.Delay.HasValue) + { + return ClampRetryDelay(retryOptions.Delay.Value, retryOptions); + } + + var initialDelay = retryOptions.InitialDelay; + if (initialDelay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var multiplier = retryOptions.BackoffMultiplier < 1D ? 1D : retryOptions.BackoffMultiplier; + var exponent = attempt <= 1 ? 0 : attempt - 1; + var delayMilliseconds = initialDelay.TotalMilliseconds * global::System.Math.Pow(multiplier, exponent); + if (double.IsNaN(delayMilliseconds) || double.IsInfinity(delayMilliseconds) || delayMilliseconds < 0D) + { + delayMilliseconds = 0D; + } + + var delay = global::System.TimeSpan.FromMilliseconds(delayMilliseconds); + delay = ApplyJitter(delay, retryOptions.JitterRatio); + return ClampRetryDelay(delay, retryOptions); + } + + internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + global::System.TimeSpan retryDelay, global::System.Threading.CancellationToken cancellationToken) { - var delay = requestOptions?.Retry?.Delay ?? - clientOptions.Retry?.Delay; - if (!delay.HasValue || delay.Value <= global::System.TimeSpan.Zero) + if (retryDelay <= global::System.TimeSpan.Zero) { return; } - await global::System.Threading.Tasks.Task.Delay(delay.Value, cancellationToken).ConfigureAwait(false); + await global::System.Threading.Tasks.Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false); + } + + private static bool TryGetRetryAfterDelay( + global::System.Net.Http.HttpResponseMessage? response, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + var retryAfter = response?.Headers.RetryAfter; + if (retryAfter == null) + { + return false; + } + + if (retryAfter.Delta.HasValue) + { + delay = retryAfter.Delta.Value; + return delay > global::System.TimeSpan.Zero; + } + + if (retryAfter.Date.HasValue) + { + delay = retryAfter.Date.Value - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static bool TryGetRateLimitResetDelay( + global::System.Net.Http.HttpResponseMessage? response, + string? headerName, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + if (response == null || string.IsNullOrWhiteSpace(headerName)) + { + return false; + } + + if (!response.Headers.TryGetValues(headerName, out var values) && + (response.Content?.Headers == null || !response.Content.Headers.TryGetValues(headerName, out values))) + { + return false; + } + + var value = global::System.Linq.Enumerable.FirstOrDefault(values); + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + value = value.Trim(); + if (long.TryParse( + value, + global::System.Globalization.NumberStyles.Integer, + global::System.Globalization.CultureInfo.InvariantCulture, + out var unixSeconds)) + { + delay = global::System.DateTimeOffset.FromUnixTimeSeconds(unixSeconds) - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + if (global::System.DateTimeOffset.TryParse( + value, + global::System.Globalization.CultureInfo.InvariantCulture, + global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal, + out var resetAt)) + { + delay = resetAt - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static global::System.TimeSpan ApplyJitter( + global::System.TimeSpan delay, + double jitterRatio) + { + if (delay <= global::System.TimeSpan.Zero || jitterRatio <= 0D) + { + return delay; + } + + if (jitterRatio > 1D) + { + jitterRatio = 1D; + } + + var sample = NextJitterSample(); + var multiplier = 1D - jitterRatio + (sample * jitterRatio * 2D); + var milliseconds = delay.TotalMilliseconds * multiplier; + if (double.IsNaN(milliseconds) || double.IsInfinity(milliseconds) || milliseconds < 0D) + { + milliseconds = 0D; + } + + return global::System.TimeSpan.FromMilliseconds(milliseconds); + } + + private static double NextJitterSample() + { + var bytes = new byte[8]; + using (var randomNumberGenerator = global::System.Security.Cryptography.RandomNumberGenerator.Create()) + { + randomNumberGenerator.GetBytes(bytes); + } + + var value = global::System.BitConverter.ToUInt64(bytes, 0); + return value / (double)ulong.MaxValue; + } + + private static global::System.TimeSpan ClampRetryDelay( + global::System.TimeSpan delay, + global::Greptile.AutoSDKRetryOptions retryOptions) + { + if (delay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var maxDelay = retryOptions.MaxDelay; + if (maxDelay > global::System.TimeSpan.Zero && delay > maxDelay) + { + return maxDelay; + } + + return delay; } internal static bool ShouldRetryStatusCode(