From eaf2e4b7a0ceb9a99cdb94df04adc9e5ea820109 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 11 Jun 2026 10:38:38 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- ...ents.CursorAgentsClient.GetAgentUsage.g.cs | 682 ++++++++++++++++++ ...nts.ICursorAgentsClient.GetAgentUsage.g.cs | 58 ++ .../CursorAgents.JsonSerializerContext.g.cs | 5 + ...rsorAgents.JsonSerializerContextTypes.g.cs | 70 +- ...Agents.Models.AgentUsageResponse.Json.g.cs | 92 +++ ...ursorAgents.Models.AgentUsageResponse.g.cs | 59 ++ .../CursorAgents.Models.RunUsage.Json.g.cs | 92 +++ .../CursorAgents.Models.RunUsage.g.cs | 76 ++ ...sorAgents.Models.UsageTokenUsage.Json.g.cs | 92 +++ .../CursorAgents.Models.UsageTokenUsage.g.cs | 110 +++ src/libs/CursorAgents/openapi.yaml | 115 +++ 11 files changed, 1426 insertions(+), 25 deletions(-) create mode 100644 src/libs/CursorAgents/Generated/CursorAgents.CursorAgentsClient.GetAgentUsage.g.cs create mode 100644 src/libs/CursorAgents/Generated/CursorAgents.ICursorAgentsClient.GetAgentUsage.g.cs create mode 100644 src/libs/CursorAgents/Generated/CursorAgents.Models.AgentUsageResponse.Json.g.cs create mode 100644 src/libs/CursorAgents/Generated/CursorAgents.Models.AgentUsageResponse.g.cs create mode 100644 src/libs/CursorAgents/Generated/CursorAgents.Models.RunUsage.Json.g.cs create mode 100644 src/libs/CursorAgents/Generated/CursorAgents.Models.RunUsage.g.cs create mode 100644 src/libs/CursorAgents/Generated/CursorAgents.Models.UsageTokenUsage.Json.g.cs create mode 100644 src/libs/CursorAgents/Generated/CursorAgents.Models.UsageTokenUsage.g.cs diff --git a/src/libs/CursorAgents/Generated/CursorAgents.CursorAgentsClient.GetAgentUsage.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.CursorAgentsClient.GetAgentUsage.g.cs new file mode 100644 index 0000000..cc1a002 --- /dev/null +++ b/src/libs/CursorAgents/Generated/CursorAgents.CursorAgentsClient.GetAgentUsage.g.cs @@ -0,0 +1,682 @@ + +#nullable enable + +namespace CursorAgents +{ + public partial class CursorAgentsClient + { + + + private static readonly global::CursorAgents.EndPointSecurityRequirement s_GetAgentUsageSecurityRequirement0 = + new global::CursorAgents.EndPointSecurityRequirement + { + Authorizations = new global::CursorAgents.EndPointAuthorizationRequirement[] + { new global::CursorAgents.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::CursorAgents.EndPointSecurityRequirement[] s_GetAgentUsageSecurityRequirements = + new global::CursorAgents.EndPointSecurityRequirement[] + { s_GetAgentUsageSecurityRequirement0, + }; + partial void PrepareGetAgentUsageArguments( + global::System.Net.Http.HttpClient httpClient, + ref string id, + ref string? runId); + partial void PrepareGetAgentUsageRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + string id, + string? runId); + partial void ProcessGetAgentUsageResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessGetAgentUsageResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Get agent usage
+ /// Retrieve token usage for an agent, broken down per run.
+ /// `totalUsage` sums input, output, and cache token counts across
+ /// every run on the agent, and `runs` lists the same breakdown for
+ /// each run. Token usage mirrors the `tokenUsage` shape on the team
+ /// usage events endpoint.
+ /// This endpoint is in early access. When it isn't enabled for the
+ /// account it returns `403 feature_unavailable`. An unknown `runId`
+ /// returns `404 run_not_found`. + ///
+ /// + /// Example: bc-00000000-0000-0000-0000-000000000001 + /// + /// + /// Example: run-00000000-0000-0000-0000-000000000001 + /// + /// 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 GetAgentUsageAsync( + string id, + string? runId = default, + global::CursorAgents.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetAgentUsageAsResponseAsync( + id: id, + runId: runId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get agent usage
+ /// Retrieve token usage for an agent, broken down per run.
+ /// `totalUsage` sums input, output, and cache token counts across
+ /// every run on the agent, and `runs` lists the same breakdown for
+ /// each run. Token usage mirrors the `tokenUsage` shape on the team
+ /// usage events endpoint.
+ /// This endpoint is in early access. When it isn't enabled for the
+ /// account it returns `403 feature_unavailable`. An unknown `runId`
+ /// returns `404 run_not_found`. + ///
+ /// + /// Example: bc-00000000-0000-0000-0000-000000000001 + /// + /// + /// Example: run-00000000-0000-0000-0000-000000000001 + /// + /// 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> GetAgentUsageAsResponseAsync( + string id, + string? runId = default, + global::CursorAgents.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareGetAgentUsageArguments( + httpClient: HttpClient, + id: ref id, + runId: ref runId); + + + var __authorizations = global::CursorAgents.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_GetAgentUsageSecurityRequirements, + operationName: "GetAgentUsageAsync"); + + using var __timeoutCancellationTokenSource = global::CursorAgents.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::CursorAgents.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::CursorAgents.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::CursorAgents.PathBuilder( + path: $"/v1/agents/{id}/usage", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("runId", runId) + ; + var __path = __pathBuilder.ToString(); + __path = global::CursorAgents.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + global::CursorAgents.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetAgentUsageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + id: id!, + runId: runId); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::CursorAgents.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAgentUsage", + methodName: "GetAgentUsageAsync", + pathTemplate: "$\"/v1/agents/{id}/usage\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::CursorAgents.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::CursorAgents.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAgentUsage", + methodName: "GetAgentUsageAsync", + pathTemplate: "$\"/v1/agents/{id}/usage\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::CursorAgents.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::CursorAgents.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::CursorAgents.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::CursorAgents.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAgentUsage", + methodName: "GetAgentUsageAsync", + pathTemplate: "$\"/v1/agents/{id}/usage\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + 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::CursorAgents.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetAgentUsageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::CursorAgents.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAgentUsage", + methodName: "GetAgentUsageAsync", + pathTemplate: "$\"/v1/agents/{id}/usage\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::CursorAgents.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetAgentUsage", + methodName: "GetAgentUsageAsync", + pathTemplate: "$\"/v1/agents/{id}/usage\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Validation error or malformed request body. + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + global::CursorAgents.Error? __value_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_400 = global::CursorAgents.Error.FromJson(__content_400, JsonSerializerContext); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_400 = global::CursorAgents.Error.FromJson(__content_400, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + + throw global::CursorAgents.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + responseBody: __content_400, + responseObject: __value_400, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Invalid or missing API key. + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + global::CursorAgents.Error? __value_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_401 = global::CursorAgents.Error.FromJson(__content_401, JsonSerializerContext); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_401 = global::CursorAgents.Error.FromJson(__content_401, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + + throw global::CursorAgents.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + responseBody: __content_401, + responseObject: __value_401, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Authenticated but insufficient permissions, plan required, or feature unavailable. + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + global::CursorAgents.Error? __value_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_403 = global::CursorAgents.Error.FromJson(__content_403, JsonSerializerContext); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_403 = global::CursorAgents.Error.FromJson(__content_403, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + + throw global::CursorAgents.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + responseBody: __content_403, + responseObject: __value_403, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Agent or run not found. + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + global::CursorAgents.Error? __value_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_404 = global::CursorAgents.Error.FromJson(__content_404, JsonSerializerContext); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_404 = global::CursorAgents.Error.FromJson(__content_404, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + + throw global::CursorAgents.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + responseBody: __content_404, + responseObject: __value_404, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Rate limit exceeded. Response includes `Retry-After`, `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` headers. + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + global::CursorAgents.Error? __value_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_429 = global::CursorAgents.Error.FromJson(__content_429, JsonSerializerContext); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_429 = global::CursorAgents.Error.FromJson(__content_429, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + + throw global::CursorAgents.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + responseBody: __content_429, + responseObject: __value_429, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + // Internal server error. + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::CursorAgents.Error? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::CursorAgents.Error.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_500 = global::CursorAgents.Error.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + + throw global::CursorAgents.ApiException.Create( + statusCode: __response.StatusCode, + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + responseBody: __content_500, + responseObject: __value_500, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetAgentUsageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::CursorAgents.AgentUsageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::CursorAgents.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::CursorAgents.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw global::CursorAgents.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::CursorAgents.AgentUsageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::CursorAgents.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::CursorAgents.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw global::CursorAgents.ApiException.Create( + statusCode: __response.StatusCode, + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + responseBody: __content, + responseHeaders: global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value)); + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + } +} \ No newline at end of file diff --git a/src/libs/CursorAgents/Generated/CursorAgents.ICursorAgentsClient.GetAgentUsage.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.ICursorAgentsClient.GetAgentUsage.g.cs new file mode 100644 index 0000000..a85c526 --- /dev/null +++ b/src/libs/CursorAgents/Generated/CursorAgents.ICursorAgentsClient.GetAgentUsage.g.cs @@ -0,0 +1,58 @@ +#nullable enable + +namespace CursorAgents +{ + public partial interface ICursorAgentsClient + { + /// + /// Get agent usage
+ /// Retrieve token usage for an agent, broken down per run.
+ /// `totalUsage` sums input, output, and cache token counts across
+ /// every run on the agent, and `runs` lists the same breakdown for
+ /// each run. Token usage mirrors the `tokenUsage` shape on the team
+ /// usage events endpoint.
+ /// This endpoint is in early access. When it isn't enabled for the
+ /// account it returns `403 feature_unavailable`. An unknown `runId`
+ /// returns `404 run_not_found`. + ///
+ /// + /// Example: bc-00000000-0000-0000-0000-000000000001 + /// + /// + /// Example: run-00000000-0000-0000-0000-000000000001 + /// + /// 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 GetAgentUsageAsync( + string id, + string? runId = default, + global::CursorAgents.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get agent usage
+ /// Retrieve token usage for an agent, broken down per run.
+ /// `totalUsage` sums input, output, and cache token counts across
+ /// every run on the agent, and `runs` lists the same breakdown for
+ /// each run. Token usage mirrors the `tokenUsage` shape on the team
+ /// usage events endpoint.
+ /// This endpoint is in early access. When it isn't enabled for the
+ /// account it returns `403 feature_unavailable`. An unknown `runId`
+ /// returns `404 run_not_found`. + ///
+ /// + /// Example: bc-00000000-0000-0000-0000-000000000001 + /// + /// + /// Example: run-00000000-0000-0000-0000-000000000001 + /// + /// 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> GetAgentUsageAsResponseAsync( + string id, + string? runId = default, + global::CursorAgents.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/CursorAgents/Generated/CursorAgents.JsonSerializerContext.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.JsonSerializerContext.g.cs index 7c04278..c0b2413 100644 --- a/src/libs/CursorAgents/Generated/CursorAgents.JsonSerializerContext.g.cs +++ b/src/libs/CursorAgents/Generated/CursorAgents.JsonSerializerContext.g.cs @@ -122,6 +122,10 @@ namespace CursorAgents [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::CursorAgents.ListArtifactsResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::CursorAgents.DownloadArtifactResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::CursorAgents.UsageTokenUsage))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::CursorAgents.RunUsage))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::CursorAgents.AgentUsageResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::CursorAgents.ApiKeyInfo))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::CursorAgents.ModelParameterValueDefinition))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::CursorAgents.ModelParameterDefinition))] @@ -152,6 +156,7 @@ namespace CursorAgents [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] diff --git a/src/libs/CursorAgents/Generated/CursorAgents.JsonSerializerContextTypes.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.JsonSerializerContextTypes.g.cs index 678ddf2..32b720f 100644 --- a/src/libs/CursorAgents/Generated/CursorAgents.JsonSerializerContextTypes.g.cs +++ b/src/libs/CursorAgents/Generated/CursorAgents.JsonSerializerContextTypes.g.cs @@ -276,79 +276,95 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::CursorAgents.ApiKeyInfo? Type62 { get; set; } + public global::CursorAgents.UsageTokenUsage? Type62 { get; set; } /// /// /// - public global::CursorAgents.ModelParameterValueDefinition? Type63 { get; set; } + public global::CursorAgents.RunUsage? Type63 { get; set; } /// /// /// - public global::CursorAgents.ModelParameterDefinition? Type64 { get; set; } + public global::CursorAgents.AgentUsageResponse? Type64 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type65 { get; set; } + public global::System.Collections.Generic.IList? Type65 { get; set; } /// /// /// - public global::CursorAgents.ModelVariant? Type66 { get; set; } + public global::CursorAgents.ApiKeyInfo? Type66 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type67 { get; set; } + public global::CursorAgents.ModelParameterValueDefinition? Type67 { get; set; } /// /// /// - public global::CursorAgents.ModelVariantParam? Type68 { get; set; } + public global::CursorAgents.ModelParameterDefinition? Type68 { get; set; } /// /// /// - public global::CursorAgents.ModelListItem? Type69 { get; set; } + public global::System.Collections.Generic.IList? Type69 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type70 { get; set; } + public global::CursorAgents.ModelVariant? Type70 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type71 { get; set; } + public global::System.Collections.Generic.IList? Type71 { get; set; } /// /// /// - public global::CursorAgents.ListModelsResponse? Type72 { get; set; } + public global::CursorAgents.ModelVariantParam? Type72 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type73 { get; set; } + public global::CursorAgents.ModelListItem? Type73 { get; set; } /// /// /// - public global::CursorAgents.Repository? Type74 { get; set; } + public global::System.Collections.Generic.IList? Type74 { get; set; } /// /// /// - public global::CursorAgents.ListRepositoriesResponse? Type75 { get; set; } + public global::System.Collections.Generic.IList? Type75 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type76 { get; set; } + public global::CursorAgents.ListModelsResponse? Type76 { get; set; } /// /// /// - public global::CursorAgents.CreateSubTokenRequest? Type77 { get; set; } + public global::System.Collections.Generic.IList? Type77 { get; set; } /// /// /// - public global::CursorAgents.CreateSubTokenResponse? Type78 { get; set; } + public global::CursorAgents.Repository? Type78 { get; set; } /// /// /// - public global::CursorAgents.Error? Type79 { get; set; } + public global::CursorAgents.ListRepositoriesResponse? Type79 { get; set; } /// /// /// - public global::CursorAgents.ErrorError1? Type80 { get; set; } + public global::System.Collections.Generic.IList? Type80 { get; set; } + /// + /// + /// + public global::CursorAgents.CreateSubTokenRequest? Type81 { get; set; } + /// + /// + /// + public global::CursorAgents.CreateSubTokenResponse? Type82 { get; set; } + /// + /// + /// + public global::CursorAgents.Error? Type83 { get; set; } + /// + /// + /// + public global::CursorAgents.ErrorError1? Type84 { get; set; } /// /// @@ -397,26 +413,30 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::System.Collections.Generic.List? ListType11 { get; set; } + public global::System.Collections.Generic.List? ListType11 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.List? ListType12 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType12 { get; set; } + public global::System.Collections.Generic.List? ListType13 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType13 { get; set; } + public global::System.Collections.Generic.List? ListType14 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType14 { get; set; } + public global::System.Collections.Generic.List? ListType15 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType15 { get; set; } + public global::System.Collections.Generic.List? ListType16 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType16 { get; set; } + public global::System.Collections.Generic.List? ListType17 { get; set; } } } \ No newline at end of file diff --git a/src/libs/CursorAgents/Generated/CursorAgents.Models.AgentUsageResponse.Json.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.Models.AgentUsageResponse.Json.g.cs new file mode 100644 index 0000000..efe8ba1 --- /dev/null +++ b/src/libs/CursorAgents/Generated/CursorAgents.Models.AgentUsageResponse.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace CursorAgents +{ + public sealed partial class AgentUsageResponse + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::CursorAgents.AgentUsageResponse? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::CursorAgents.AgentUsageResponse), + jsonSerializerContext) as global::CursorAgents.AgentUsageResponse; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::CursorAgents.AgentUsageResponse? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::CursorAgents.AgentUsageResponse), + jsonSerializerContext).ConfigureAwait(false)) as global::CursorAgents.AgentUsageResponse; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/CursorAgents/Generated/CursorAgents.Models.AgentUsageResponse.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.Models.AgentUsageResponse.g.cs new file mode 100644 index 0000000..be4828b --- /dev/null +++ b/src/libs/CursorAgents/Generated/CursorAgents.Models.AgentUsageResponse.g.cs @@ -0,0 +1,59 @@ + +#nullable enable + +namespace CursorAgents +{ + /// + /// + /// + public sealed partial class AgentUsageResponse + { + /// + /// Token usage summed across the returned runs. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("totalUsage")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::CursorAgents.UsageTokenUsage TotalUsage { get; set; } + + /// + /// Per-run usage, one entry per run (or a single entry when `runId` is set). + /// + [global::System.Text.Json.Serialization.JsonPropertyName("runs")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::System.Collections.Generic.IList Runs { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Token usage summed across the returned runs. + /// + /// + /// Per-run usage, one entry per run (or a single entry when `runId` is set). + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public AgentUsageResponse( + global::CursorAgents.UsageTokenUsage totalUsage, + global::System.Collections.Generic.IList runs) + { + this.TotalUsage = totalUsage ?? throw new global::System.ArgumentNullException(nameof(totalUsage)); + this.Runs = runs ?? throw new global::System.ArgumentNullException(nameof(runs)); + } + + /// + /// Initializes a new instance of the class. + /// + public AgentUsageResponse() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/CursorAgents/Generated/CursorAgents.Models.RunUsage.Json.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.Models.RunUsage.Json.g.cs new file mode 100644 index 0000000..c979312 --- /dev/null +++ b/src/libs/CursorAgents/Generated/CursorAgents.Models.RunUsage.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace CursorAgents +{ + public sealed partial class RunUsage + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::CursorAgents.RunUsage? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::CursorAgents.RunUsage), + jsonSerializerContext) as global::CursorAgents.RunUsage; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::CursorAgents.RunUsage? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::CursorAgents.RunUsage), + jsonSerializerContext).ConfigureAwait(false)) as global::CursorAgents.RunUsage; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/CursorAgents/Generated/CursorAgents.Models.RunUsage.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.Models.RunUsage.g.cs new file mode 100644 index 0000000..788ee7d --- /dev/null +++ b/src/libs/CursorAgents/Generated/CursorAgents.Models.RunUsage.g.cs @@ -0,0 +1,76 @@ + +#nullable enable + +namespace CursorAgents +{ + /// + /// + /// + public sealed partial class RunUsage + { + /// + /// Run identifier.
+ /// Example: run-00000000-0000-0000-0000-000000000001 + ///
+ /// run-00000000-0000-0000-0000-000000000001 + [global::System.Text.Json.Serialization.JsonPropertyName("id")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string Id { get; set; } + + /// + /// Internal usage identifier for the run. Omitted when the run has no recorded usage yet.
+ /// Example: 00000000-0000-0000-0000-000000000001 + ///
+ /// 00000000-0000-0000-0000-000000000001 + [global::System.Text.Json.Serialization.JsonPropertyName("usageUuid")] + public string? UsageUuid { get; set; } + + /// + /// Token usage for this run. Runs without recorded usage report zeros across all fields. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("usage")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::CursorAgents.UsageTokenUsage Usage { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Run identifier.
+ /// Example: run-00000000-0000-0000-0000-000000000001 + /// + /// + /// Token usage for this run. Runs without recorded usage report zeros across all fields. + /// + /// + /// Internal usage identifier for the run. Omitted when the run has no recorded usage yet.
+ /// Example: 00000000-0000-0000-0000-000000000001 + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public RunUsage( + string id, + global::CursorAgents.UsageTokenUsage usage, + string? usageUuid) + { + this.Id = id ?? throw new global::System.ArgumentNullException(nameof(id)); + this.UsageUuid = usageUuid; + this.Usage = usage ?? throw new global::System.ArgumentNullException(nameof(usage)); + } + + /// + /// Initializes a new instance of the class. + /// + public RunUsage() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/CursorAgents/Generated/CursorAgents.Models.UsageTokenUsage.Json.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.Models.UsageTokenUsage.Json.g.cs new file mode 100644 index 0000000..179ca86 --- /dev/null +++ b/src/libs/CursorAgents/Generated/CursorAgents.Models.UsageTokenUsage.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace CursorAgents +{ + public sealed partial class UsageTokenUsage + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::CursorAgents.UsageTokenUsage? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::CursorAgents.UsageTokenUsage), + jsonSerializerContext) as global::CursorAgents.UsageTokenUsage; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::CursorAgents.UsageTokenUsage? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::CursorAgents.UsageTokenUsage), + jsonSerializerContext).ConfigureAwait(false)) as global::CursorAgents.UsageTokenUsage; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/CursorAgents/Generated/CursorAgents.Models.UsageTokenUsage.g.cs b/src/libs/CursorAgents/Generated/CursorAgents.Models.UsageTokenUsage.g.cs new file mode 100644 index 0000000..dd1b309 --- /dev/null +++ b/src/libs/CursorAgents/Generated/CursorAgents.Models.UsageTokenUsage.g.cs @@ -0,0 +1,110 @@ + +#nullable enable + +namespace CursorAgents +{ + /// + /// + /// + public sealed partial class UsageTokenUsage + { + /// + /// Input tokens consumed.
+ /// Example: 6320 + ///
+ /// 6320 + [global::System.Text.Json.Serialization.JsonPropertyName("inputTokens")] + [global::System.Text.Json.Serialization.JsonRequired] + public required int InputTokens { get; set; } + + /// + /// Output tokens generated.
+ /// Example: 1450 + ///
+ /// 1450 + [global::System.Text.Json.Serialization.JsonPropertyName("outputTokens")] + [global::System.Text.Json.Serialization.JsonRequired] + public required int OutputTokens { get; set; } + + /// + /// Tokens written to cache.
+ /// Example: 7100 + ///
+ /// 7100 + [global::System.Text.Json.Serialization.JsonPropertyName("cacheWriteTokens")] + [global::System.Text.Json.Serialization.JsonRequired] + public required int CacheWriteTokens { get; set; } + + /// + /// Tokens read from cache.
+ /// Example: 21300 + ///
+ /// 21300 + [global::System.Text.Json.Serialization.JsonPropertyName("cacheReadTokens")] + [global::System.Text.Json.Serialization.JsonRequired] + public required int CacheReadTokens { get; set; } + + /// + /// Sum of the four token counts above.
+ /// Example: 36170 + ///
+ /// 36170 + [global::System.Text.Json.Serialization.JsonPropertyName("totalTokens")] + [global::System.Text.Json.Serialization.JsonRequired] + public required int TotalTokens { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Input tokens consumed.
+ /// Example: 6320 + /// + /// + /// Output tokens generated.
+ /// Example: 1450 + /// + /// + /// Tokens written to cache.
+ /// Example: 7100 + /// + /// + /// Tokens read from cache.
+ /// Example: 21300 + /// + /// + /// Sum of the four token counts above.
+ /// Example: 36170 + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public UsageTokenUsage( + int inputTokens, + int outputTokens, + int cacheWriteTokens, + int cacheReadTokens, + int totalTokens) + { + this.InputTokens = inputTokens; + this.OutputTokens = outputTokens; + this.CacheWriteTokens = cacheWriteTokens; + this.CacheReadTokens = cacheReadTokens; + this.TotalTokens = totalTokens; + } + + /// + /// Initializes a new instance of the class. + /// + public UsageTokenUsage() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/CursorAgents/openapi.yaml b/src/libs/CursorAgents/openapi.yaml index 5bbb9eb..3f8c237 100644 --- a/src/libs/CursorAgents/openapi.yaml +++ b/src/libs/CursorAgents/openapi.yaml @@ -763,6 +763,78 @@ components: format: date-time description: When the presigned URL expires. + UsageTokenUsage: + type: object + required: + - inputTokens + - outputTokens + - cacheWriteTokens + - cacheReadTokens + - totalTokens + properties: + inputTokens: + type: integer + minimum: 0 + description: Input tokens consumed. + example: 6320 + outputTokens: + type: integer + minimum: 0 + description: Output tokens generated. + example: 1450 + cacheWriteTokens: + type: integer + minimum: 0 + description: Tokens written to cache. + example: 7100 + cacheReadTokens: + type: integer + minimum: 0 + description: Tokens read from cache. + example: 21300 + totalTokens: + type: integer + minimum: 0 + description: Sum of the four token counts above. + example: 36170 + + RunUsage: + type: object + required: + - id + - usage + properties: + id: + type: string + minLength: 1 + description: Run identifier. + example: 'run-00000000-0000-0000-0000-000000000001' + usageUuid: + type: string + minLength: 1 + description: Internal usage identifier for the run. Omitted when the run has no recorded usage yet. + example: '00000000-0000-0000-0000-000000000001' + usage: + allOf: + - $ref: '#/components/schemas/UsageTokenUsage' + description: Token usage for this run. Runs without recorded usage report zeros across all fields. + + AgentUsageResponse: + type: object + required: + - totalUsage + - runs + properties: + totalUsage: + allOf: + - $ref: '#/components/schemas/UsageTokenUsage' + description: Token usage summed across the returned runs. + runs: + type: array + description: Per-run usage, one entry per run (or a single entry when `runId` is set). + items: + $ref: '#/components/schemas/RunUsage' + ApiKeyInfo: type: object required: @@ -1442,6 +1514,49 @@ paths: '500': $ref: '#/components/responses/InternalError' + /v1/agents/{id}/usage: + get: + summary: Get agent usage + description: | + Retrieve token usage for an agent, broken down per run. + `totalUsage` sums input, output, and cache token counts across + every run on the agent, and `runs` lists the same breakdown for + each run. Token usage mirrors the `tokenUsage` shape on the team + usage events endpoint. + + This endpoint is in early access. When it isn't enabled for the + account it returns `403 feature_unavailable`. An unknown `runId` + returns `404 run_not_found`. + operationId: getAgentUsage + parameters: + - $ref: '#/components/parameters/AgentId' + - name: runId + in: query + required: false + description: Scope usage to a single run. Omit to return usage for every run on the agent. + schema: + type: string + example: 'run-00000000-0000-0000-0000-000000000001' + responses: + '200': + description: Usage retrieved successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/AgentUsageResponse' + '400': + $ref: '#/components/responses/BadRequest' + '401': + $ref: '#/components/responses/Unauthorized' + '403': + $ref: '#/components/responses/Forbidden' + '404': + $ref: '#/components/responses/NotFound' + '429': + $ref: '#/components/responses/RateLimited' + '500': + $ref: '#/components/responses/InternalError' + /v1/agents/{id}/archive: post: summary: Archive an agent