Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ public sealed partial class CursorAgentsClient
{

/// <inheritdoc/>
public void AuthorizeUsingBearer(
string apiKey)
public void AuthorizeUsingBasic(
string username,
string password)
{
apiKey = apiKey ?? throw new global::System.ArgumentNullException(nameof(apiKey));
username = username ?? throw new global::System.ArgumentNullException(nameof(username));
password = password ?? throw new global::System.ArgumentNullException(nameof(password));

for (var i = Authorizations.Count - 1; i >= 0; i--)
{
var __authorization = Authorizations[i];
if (__authorization.Type == "Http" &&
__authorization.Name == "Bearer")
__authorization.Name == "Basic")
{
Authorizations.RemoveAt(i);
}
Expand All @@ -25,10 +27,11 @@ public void AuthorizeUsingBearer(
Authorizations.Add(new global::CursorAgents.EndPointAuthorization
{
Type = "Http",
SchemeId = "BearerAuth",
SchemeId = "BasicAuth",
Location = "Header",
Name = "Bearer",
Value = apiKey,
Name = "Basic",
Value = global::System.Convert.ToBase64String(
global::System.Text.Encoding.UTF8.GetBytes($"{username}:{password}")),
});
}
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ public sealed partial class CursorAgentsClient
/// <inheritdoc cref="CursorAgentsClient(global::System.Net.Http.HttpClient?, global::System.Uri?, global::System.Collections.Generic.List{global::CursorAgents.EndPointAuthorization}?, bool)"/>

public CursorAgentsClient(
string apiKey,
string username,
string password,
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null,
global::System.Collections.Generic.List<global::CursorAgents.EndPointAuthorization>? authorizations = null,
bool disposeHttpClient = true) : this(httpClient, baseUri, authorizations, disposeHttpClient)
{
Authorizing(HttpClient, ref apiKey);
Authorizing(HttpClient, ref username, ref password);

AuthorizeUsingBearer(apiKey);
AuthorizeUsingBasic(username, password);

Authorized(HttpClient);
}

partial void Authorizing(
global::System.Net.Http.HttpClient client,
ref string apiKey);
ref string username,
ref string password);
partial void Authorized(
global::System.Net.Http.HttpClient client);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public partial class CursorAgentsClient
{ new global::CursorAgents.EndPointAuthorizationRequirement
{
Type = "Http",
SchemeId = "BearerAuth",
SchemeId = "BasicAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
Name = "Basic",
FriendlyName = "Basic",
},
},
};
Expand All @@ -42,8 +42,10 @@ partial void ProcessCreateAgentResponseContent(
ref string content);

/// <summary>
/// Launch an agent<br/>
/// Start a new cloud agent to work on your repository
/// Create an agent<br/>
/// Create a Cloud Agent and immediately enqueue its initial run.<br/>
/// The response contains both the durable `agent` and the initial<br/>
/// `run`.
/// </summary>
/// <param name="request"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
Expand Down Expand Up @@ -86,7 +88,7 @@ partial void ProcessCreateAgentResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
var __pathBuilder = new global::CursorAgents.PathBuilder(
path: "/v0/agents",
path: "/v1/agents",
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
__path = global::CursorAgents.AutoSDKRequestOptionsSupport.AppendQueryParameters(
Expand Down Expand Up @@ -153,7 +155,7 @@ partial void ProcessCreateAgentResponseContent(
context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext(
operationId: "CreateAgent",
methodName: "CreateAgentAsync",
pathTemplate: "\"/v0/agents\"",
pathTemplate: "\"/v1/agents\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
Expand All @@ -180,7 +182,7 @@ partial void ProcessCreateAgentResponseContent(
context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext(
operationId: "CreateAgent",
methodName: "CreateAgentAsync",
pathTemplate: "\"/v0/agents\"",
pathTemplate: "\"/v1/agents\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
Expand Down Expand Up @@ -215,7 +217,7 @@ partial void ProcessCreateAgentResponseContent(
context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext(
operationId: "CreateAgent",
methodName: "CreateAgentAsync",
pathTemplate: "\"/v0/agents\"",
pathTemplate: "\"/v1/agents\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
Expand Down Expand Up @@ -262,7 +264,7 @@ partial void ProcessCreateAgentResponseContent(
context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext(
operationId: "CreateAgent",
methodName: "CreateAgentAsync",
pathTemplate: "\"/v0/agents\"",
pathTemplate: "\"/v1/agents\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
Expand All @@ -282,7 +284,7 @@ partial void ProcessCreateAgentResponseContent(
context: global::CursorAgents.AutoSDKRequestOptionsSupport.CreateHookContext(
operationId: "CreateAgent",
methodName: "CreateAgentAsync",
pathTemplate: "\"/v0/agents\"",
pathTemplate: "\"/v1/agents\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
Expand All @@ -295,7 +297,7 @@ partial void ProcessCreateAgentResponseContent(
willRetry: false,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
// Invalid request
// Validation error or malformed request body.
if ((int)__response.StatusCode == 400)
{
string? __content_400 = null;
Expand Down Expand Up @@ -333,7 +335,7 @@ partial void ProcessCreateAgentResponseContent(
h => h.Value),
};
}
// Unauthorized - invalid or missing API key
// Invalid or missing API key.
if ((int)__response.StatusCode == 401)
{
string? __content_401 = null;
Expand Down Expand Up @@ -371,7 +373,7 @@ partial void ProcessCreateAgentResponseContent(
h => h.Value),
};
}
// Forbidden - insufficient permissions, plan limits exceeded, or storage full
// Authenticated but insufficient permissions, plan required, or feature unavailable.
if ((int)__response.StatusCode == 403)
{
string? __content_403 = null;
Expand Down Expand Up @@ -409,7 +411,7 @@ partial void ProcessCreateAgentResponseContent(
h => h.Value),
};
}
// Rate limit exceeded
// 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;
Expand Down Expand Up @@ -447,7 +449,7 @@ partial void ProcessCreateAgentResponseContent(
h => h.Value),
};
}
// Internal server error
// Internal server error.
if ((int)__response.StatusCode == 500)
{
string? __content_500 = null;
Expand Down Expand Up @@ -578,36 +580,55 @@ partial void ProcessCreateAgentResponseContent(
}
}
/// <summary>
/// Launch an agent<br/>
/// Start a new cloud agent to work on your repository
/// Create an agent<br/>
/// Create a Cloud Agent and immediately enqueue its initial run.<br/>
/// The response contains both the durable `agent` and the initial<br/>
/// `run`.
/// </summary>
/// <param name="prompt"></param>
/// <param name="model">
/// Set to an explicit model ID for launch requests, or use "default" to use the configured default model. When omitted, Cursor resolves your user default model, then your team default model, then a system default.<br/>
/// Example: claude-4-sonnet
/// <param name="model"></param>
/// <param name="repos">
/// Repository configuration. v1 currently supports one entry.
/// </param>
/// <param name="branchName">
/// Custom branch name for the agent to create.<br/>
/// Example: feature/add-readme
/// </param>
/// <param name="autoGenerateBranch">
/// Whether to create a new branch (true) or push to an existing head branch (false). Only applies when `repos[0].prUrl` is provided.<br/>
/// Default Value: true
/// </param>
/// <param name="autoCreatePR">
/// Whether Cursor should open a pull request when the run completes.<br/>
/// Default Value: false
/// </param>
/// <param name="skipReviewerRequest">
/// Whether to skip requesting the user as a reviewer when Cursor opens a PR. Only applies when `autoCreatePR` is true.<br/>
/// Default Value: false
/// </param>
/// <param name="source"></param>
/// <param name="target"></param>
/// <param name="webhook"></param>
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::CursorAgents.CreateAgentResponse> CreateAgentAsync(
global::CursorAgents.CreateAgentRequestPrompt prompt,
global::CursorAgents.CreateAgentRequestSource source,
string? model = default,
global::CursorAgents.CreateAgentRequestTarget? target = default,
global::CursorAgents.CreateAgentRequestWebhook? webhook = default,
global::System.Collections.Generic.IList<global::CursorAgents.RepoConfig> repos,
global::CursorAgents.ModelRef? model = default,
string? branchName = default,
bool? autoGenerateBranch = default,
bool? autoCreatePR = default,
bool? skipReviewerRequest = default,
global::CursorAgents.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::CursorAgents.CreateAgentRequest
{
Prompt = prompt,
Model = model,
Source = source,
Target = target,
Webhook = webhook,
Repos = repos,
BranchName = branchName,
AutoGenerateBranch = autoGenerateBranch,
AutoCreatePR = autoCreatePR,
SkipReviewerRequest = skipReviewerRequest,
};

return await CreateAgentAsync(
Expand Down
Loading
Loading