import type { Endpoints } from '@octokit/types'; import { CCAModel } from '@vscode/copilot-api'; import { ICAPIClientService } from '../../endpoint/common/capiClient'; import { ILogService } from '../../log/common/logService'; import { IFetcherService } from '../../networking/common/fetcherService'; import { ITelemetryService } from '../../telemetry/common/telemetry'; import { AssignableActor, PullRequestSearchItem } from './githubAPI'; /** * Options for controlling authentication behavior in OctoKit service methods. */ export interface AuthOptions { /** * If provided, prompts the user to sign in if no authentication token is available, * displaying the given detail message to explain why authentication is needed. * If undefined, fails silently without prompting. */ readonly createIfNone?: { readonly detail: string; }; } export type IGetRepositoryInfoResponseData = Endpoints['GET /repos/{owner}/{repo}']['response']['data']; export declare const IGithubRepositoryService: import("../../../util/common/services").ServiceIdentifier; export declare const IOctoKitService: import("../../../util/common/services").ServiceIdentifier; export declare const VSCodeTeamId = 1682102; export type GithubRepositoryItem = { name: string; path: string; html_url: string; type: 'file' | 'dir'; }; export interface IGithubRepositoryService { _serviceBrand: undefined; /** * Returns whether the given repository is available via GitHub APIs. * @param org The GitHub organization * @param repo The GitHub repository */ isAvailable(org: string, repo: string): Promise; getRepositoryInfo(owner: string, repo: string): Promise; getRepositoryItems(org: string, repo: string, path: string): Promise; getRepositoryItemContent(org: string, repo: string, path: string): Promise; } export interface IOctoKitUser { id: number; login: string; name: string | null; avatar_url: string; } /** * Result of checking if Copilot cloud agent is enabled for a repository. */ export interface CCAEnabledResult { /** * Whether the cloud agent is enabled. `undefined` if unable to determine. */ enabled: boolean | undefined; /** * The HTTP status code from the /enabled response. Known values: 401, 403, 422. * Unexpected values (e.g. 429 rate-limit, 5xx) are also propagated for telemetry. */ statusCode?: number; } export interface CustomAgentListItem { name: string; repo_owner_id: number; repo_owner: string; repo_id: number; repo_name: string; display_name: string; description: string; tools: string[]; version: string; argument_hint?: string; metadata?: Record; target?: string; config_error?: string; model?: string; disable_model_invocation?: boolean; user_invocable?: boolean; 'mcp-servers'?: { [serverName: string]: { type: string; command?: string; args?: string[]; tools?: string[]; env?: { [key: string]: string; }; headers?: { [key: string]: string; }; }; }; } export interface CustomAgentListOptions { target?: 'github-copilot' | 'vscode'; excludeInvalidConfig?: boolean; dedupe?: boolean; includeSources?: ('repo' | 'org' | 'enterprise')[]; } export interface CustomAgentListOptions { target?: 'github-copilot' | 'vscode'; excludeInvalidConfig?: boolean; dedupe?: boolean; includeSources?: ('repo' | 'org' | 'enterprise')[]; } export interface CustomAgentDetails extends CustomAgentListItem { prompt: string; } export interface PullRequestFile { filename: string; status: 'added' | 'removed' | 'modified' | 'renamed' | 'copied' | 'changed' | 'unchanged'; additions: number; deletions: number; changes: number; patch?: string; previous_filename?: string; sha?: string; } /** * Result of comparing two refs via the GitHub REST compare API. `baseSha`/`headSha` are * the resolved commit SHAs that bound the {@link files} diff (base is the merge base). */ export interface RepositoryComparison { readonly baseSha: string; readonly headSha: string; readonly files: readonly PullRequestFile[]; } export interface CreatedPullRequest { number: number; url: string; } export declare const enum GitHubOutageStatus { None = 0, Minor = 1, Major = 2, Critical = 3 } export declare class PermissiveAuthRequiredError extends Error { constructor(); } export interface IOctoKitService { _serviceBrand: undefined; /** * @returns The currently authenticated user or undefined if there isn't one */ getCurrentAuthedUser(): Promise; /** * Returns the list of Copilot pull requests for a given user on a specific repo. * @param authOptions - Authentication options. By default, uses silent auth and returns empty array if not authenticated. */ getOpenPullRequestsForUser(owner: string, repo: string, authOptions: AuthOptions): Promise; /** * Creates a pull request. * @param owner The repository owner * @param repo The repository name * @param title The pull request title * @param body The pull request body * @param head The source branch name * @param base The target branch name * @param draft Whether to create the PR as a draft * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. */ createPullRequest(owner: string, repo: string, title: string, body: string, head: string, base: string, draft: boolean, authOptions: AuthOptions): Promise; /** * Gets pull request from global id. * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. */ getPullRequestFromGlobalId(globalId: string, authOptions: AuthOptions): Promise; /** * Gets the list of custom agents available for a repository. * This includes both repo-level and org/enterprise-level custom agents. * @param owner The repository owner * @param repo The repository name * @param options Optional filtering options: * - targetPlatform: Only include agents for the specified platform. * - excludeInvalidConfigs: Exclude agents with invalid configurations. * - deduplicate: Remove duplicate agents from the result. * - source: Filter agents by their source (repo, org, enterprise). * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @returns An array of custom agent list items with basic metadata */ getCustomAgents(owner: string, repo: string, options: CustomAgentListOptions, authOptions: AuthOptions): Promise; /** * Gets the full configuration for a specific custom agent. * @param owner The repository owner * @param repo The repository name * @param agentName The name of the custom agent * @param version Optional git ref (branch, tag, or commit SHA) to fetch from * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @returns The complete custom agent configuration including the prompt */ getCustomAgentDetails(owner: string, repo: string, agentName: string, version: string, authOptions: AuthOptions): Promise; /** * Gets the list of files changed in a pull request. * @param owner The repository owner * @param repo The repository name * @param pullNumber The pull request number * @param authOptions - Authentication options. By default, uses silent auth and returns empty array if not authenticated. * @returns An array of changed files with their metadata */ getPullRequestFiles(owner: string, repo: string, pullNumber: number, authOptions: AuthOptions): Promise; /** * Compares two refs via the GitHub REST compare API * (`GET /repos/{owner}/{repo}/compare/{base}...{head}`), returning the changed files plus * the resolved merge-base and head commit SHAs. Used to surface file changes for cloud * tasks that pushed a branch but have no pull request yet. * @param authOptions - Authentication options. By default, uses silent auth and returns undefined if not authenticated. */ compareCommits(owner: string, repo: string, base: string, head: string, authOptions: AuthOptions): Promise; /** * Resolves a repository's `{owner, name}` from its numeric database id via * `GET /repositories/{id}`. Used to recover repo identity for Task API payloads that only * carry `repository.id` (no name-with-owner). * @param authOptions - Authentication options. By default, uses silent auth and returns undefined if not authenticated or not found. */ getRepositoryById(id: number, authOptions: AuthOptions): Promise<{ owner: string; name: string; } | undefined>; /** * Closes a pull request. * @param owner The repository owner * @param repo The repository name * @param pullNumber The pull request number * @param authOptions - Authentication options. By default, uses silent auth and returns false if not authenticated. * @returns A promise that resolves to true if the PR was successfully closed */ closePullRequest(owner: string, repo: string, pullNumber: number, authOptions: AuthOptions): Promise; /** * Finds a pull request by its head branch name in a given repository. * @param owner The repository owner * @param repo The repository name * @param headBranch The head branch name to search for * @param authOptions - Authentication options. By default, uses silent auth and returns undefined if not authenticated. * @returns The matching pull request or undefined if not found */ findPullRequestByHeadBranch(owner: string, repo: string, headBranch: string, authOptions: AuthOptions): Promise; /** * Get file content from a specific commit. * @param owner The repository owner * @param repo The repository name * @param ref The commit SHA, branch name, or tag * @param path The file path within the repository * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @returns The file content as a string */ getFileContent(owner: string, repo: string, ref: string, path: string, authOptions: AuthOptions): Promise; /** * Gets the list of organizations that the authenticated user belongs to. * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @param pageSize - Number of organizations to fetch per page (max and default: 100) * @returns An array of organization logins */ getUserOrganizations(authOptions: AuthOptions, pageSize?: number): Promise; /** * Checks if the authenticated user is a member of a specific organization. * This makes a direct API call and avoids pagination issues with getUserOrganizations. * @param org The organization login to check membership for * @param authOptions - Authentication options. By default, uses silent auth. * @returns True if the user is a member, false otherwise */ isUserMemberOfOrg(org: string, authOptions: AuthOptions): Promise; /** * Gets the list of repositories for an organization. * @param org The organization name * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @param pageSize - Number of repositories to fetch per page (max and default: 100) * @returns An array of repository names */ getOrganizationRepositories(org: string, authOptions: AuthOptions, pageSize?: number): Promise; /** * Gets the custom instructions prompt for an organization. * @param orgLogin The organization login * @returns The prompt string or undefined if not available */ getOrgCustomInstructions(orgLogin: string, authOptions: AuthOptions): Promise; /** * Gets the list of repositories the authenticated user has access to. * This includes repositories the user owns, collaborates on, and has access to through organization membership. * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @param query - Optional search query to filter repositories by name. * @returns An array of repositories with owner/name format */ getUserRepositories(authOptions: AuthOptions, query?: string): Promise<{ owner: string; name: string; }[]>; /** * Gets the list of repositories the authenticated user has recently committed to. * Uses the GitHub Events API to find repositories from recent PushEvent activity. * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @returns An array of repositories with owner/name format, ordered by most recent commit */ getRecentlyCommittedRepositories(authOptions: AuthOptions): Promise<{ owner: string; name: string; }[]>; /** * Gets the list of available models for the Copilot coding agent. * Returns an empty array if the user doesn't have access to the model picker * (e.g., Copilot Business or Enterprise users before rollout). * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @returns An array of available models. The first model is always 'Auto' and should be the default. */ getCopilotAgentModels(authOptions: AuthOptions): Promise; /** * Gets the list of assignable actors (users/bots) for a repository. * This is used to check if partner agents like Copilot are available for assignment. * @param owner The repository owner * @param repo The repository name * @param authOptions - Authentication options. By default, uses silent auth and throws {@link PermissiveAuthRequiredError} if not authenticated. * @returns An array of assignable actors with their login names */ getAssignableActors(owner: string, repo: string, authOptions: AuthOptions): Promise; /** * Checks if the Copilot cloud agent is enabled for a repository. * @param owner The repository owner * @param repo The repository name * @param authOptions - Authentication options. By default, uses silent auth. * @returns An object indicating enabled status and status code if disabled. * - 200: enabled = true * - 401: enabled = false, statusCode = 401 * - 403: enabled = false, statusCode = 403 * - 422: enabled = false, statusCode = 422 * - Other errors: enabled = undefined */ isCCAEnabled(owner: string, repo: string, authOptions: AuthOptions): Promise; getGitHubOutageStatus(): Promise; } /** * The same as {@link OctoKitService} but doesn't require the AuthService. * This is because we want to call certain Octokit method inside the Authservice and must * avoid a circular dependency. * Note: Only OctoKitService is exposed on the accessor to avoid confusion. */ export declare class BaseOctoKitService { protected readonly _capiClientService: ICAPIClientService; protected readonly _fetcherService: IFetcherService; protected readonly _logService: ILogService; protected readonly _telemetryService: ITelemetryService; private static readonly _outageStatusCacheTTL; private _cachedOutageStatus; private static readonly _userReposScopeCacheTTL; private _cachedUserReposScope; constructor(_capiClientService: ICAPIClientService, _fetcherService: IFetcherService, _logService: ILogService, _telemetryService: ITelemetryService); getCurrentAuthedUserWithToken(token: string): Promise; getGitHubOutageStatus(): Promise; protected _makeGHAPIRequest(routeSlug: string, method: 'GET' | 'POST', token: string, body?: { [key: string]: any; }, options?: { silent404?: boolean; }, callSite?: string): Promise; protected getOpenPullRequestForUserWithToken(owner: string, repo: string, user: string, token: string): Promise; protected findPullRequestByHeadBranchWithToken(owner: string, repo: string, headBranch: string, token: string): Promise; protected createPullRequestWithToken(owner: string, repo: string, title: string, body: string, head: string, base: string, draft: boolean, token: string): Promise; protected getPullRequestFromSessionWithToken(globalId: string, token: string): Promise; protected getPullRequestFilesWithToken(owner: string, repo: string, pullNumber: number, token: string): Promise; protected compareCommitsWithToken(owner: string, repo: string, base: string, head: string, token: string): Promise; protected getRepositoryByIdWithToken(id: number, token: string): Promise<{ owner: string; name: string; } | undefined>; protected closePullRequestWithToken(owner: string, repo: string, pullNumber: number, token: string): Promise; protected getFileContentWithToken(owner: string, repo: string, ref: string, path: string, token: string): Promise; protected getUserOrganizationsWithToken(token: string, pageSize?: number): Promise; protected isUserMemberOfOrgWithToken(org: string, token: string): Promise; protected getOrganizationRepositoriesWithToken(org: string, token: string, pageSize?: number): Promise; protected getUserRepositoriesWithToken(token: string, query?: string): Promise<{ owner: string; name: string; }[]>; private searchUserRepositoriesWithToken; private _getUserReposSearchScope; protected getRecentlyCommittedReposWithToken(token: string): Promise<{ owner: string; name: string; }[]>; private getBlobContentWithToken; } //# sourceMappingURL=githubService.d.ts.map