| | | 1 | | namespace NexusLabs.Needlr.Copilot; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Configuration options for <see cref="CopilotChatClient"/> and related Copilot API types. |
| | | 5 | | /// </summary> |
| | | 6 | | public sealed class CopilotChatClientOptions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// The default model to use when <see cref="Microsoft.Extensions.AI.ChatOptions.ModelId"/> |
| | | 10 | | /// is not specified by the caller. Defaults to <c>claude-sonnet-4</c>. |
| | | 11 | | /// </summary> |
| | 37 | 12 | | public string DefaultModel { get; set; } = "claude-sonnet-4"; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Controls where the GitHub OAuth token is sourced from. |
| | | 16 | | /// Defaults to <see cref="CopilotTokenSource.Auto"/>. |
| | | 17 | | /// </summary> |
| | 2 | 18 | | public CopilotTokenSource TokenSource { get; set; } = CopilotTokenSource.Auto; |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Optional explicit GitHub OAuth token. When set, takes precedence over |
| | | 22 | | /// <see cref="TokenSource"/> discovery. |
| | | 23 | | /// </summary> |
| | 48 | 24 | | public string? GitHubToken { get; set; } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// The Copilot API base URL. Defaults to <c>https://api.githubcopilot.com</c>. |
| | | 28 | | /// </summary> |
| | 43 | 29 | | public string CopilotApiBaseUrl { get; set; } = "https://api.githubcopilot.com"; |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// The GitHub API base URL for token exchange. |
| | | 33 | | /// Defaults to <c>https://api.github.com</c>. |
| | | 34 | | /// </summary> |
| | 40 | 35 | | public string GitHubApiBaseUrl { get; set; } = "https://api.github.com"; |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Value sent in the <c>Copilot-Integration-Id</c> header. |
| | | 39 | | /// Defaults to <c>needlr-copilot</c>. |
| | | 40 | | /// </summary> |
| | 71 | 41 | | public string IntegrationId { get; set; } = "copilot-developer-cli"; |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Value sent in the <c>Editor-Version</c> header. |
| | | 45 | | /// Defaults to <c>NexusLabs.Needlr/1.0.0</c>. |
| | | 46 | | /// </summary> |
| | 36 | 47 | | public string EditorVersion { get; set; } = "NexusLabs.Needlr/1.0.0"; |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// How many seconds before the Copilot API token expires to trigger a refresh. |
| | | 51 | | /// Defaults to 60. |
| | | 52 | | /// </summary> |
| | 28 | 53 | | public int TokenRefreshBufferSeconds { get; set; } = 60; |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Maximum number of retries on HTTP 429 (Too Many Requests) responses. |
| | | 57 | | /// Defaults to 3. Set to 0 to disable retries. |
| | | 58 | | /// </summary> |
| | 40 | 59 | | public int MaxRetries { get; set; } = 3; |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Initial delay in milliseconds before the first retry on 429. |
| | | 63 | | /// Subsequent retries use exponential backoff (delay × 2^attempt). |
| | | 64 | | /// If the response includes a <c>Retry-After</c> header, that value |
| | | 65 | | /// is used instead. Defaults to 1000ms. |
| | | 66 | | /// </summary> |
| | 34 | 67 | | public int RetryBaseDelayMs { get; set; } = 1000; |
| | | 68 | | } |