@shipfox/api-integration-github 12.3.0 → 12.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +19 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +15 -9
- package/dist/api/client.js.map +1 -1
- package/dist/api/github-octokit.d.ts +7 -0
- package/dist/api/github-octokit.d.ts.map +1 -0
- package/dist/api/github-octokit.js +32 -0
- package/dist/api/github-octokit.js.map +1 -0
- package/dist/api/installation-token-envelope.d.ts +5 -1
- package/dist/api/installation-token-envelope.d.ts.map +1 -1
- package/dist/api/installation-token-envelope.js +16 -5
- package/dist/api/installation-token-envelope.js.map +1 -1
- package/dist/api/installation-token-provider.d.ts.map +1 -1
- package/dist/api/installation-token-provider.js +4 -2
- package/dist/api/installation-token-provider.js.map +1 -1
- package/dist/api/shared-installation-token-cache.d.ts.map +1 -1
- package/dist/api/shared-installation-token-cache.js +10 -4
- package/dist/api/shared-installation-token-cache.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-tools.d.ts +11 -4
- package/dist/core/agent-tools.d.ts.map +1 -1
- package/dist/core/agent-tools.js +235 -24
- package/dist/core/agent-tools.js.map +1 -1
- package/dist/core/github-agent-tool-catalog.js +1 -1
- package/dist/core/github-agent-tool-catalog.js.map +1 -1
- package/dist/metrics/instance.d.ts +1 -0
- package/dist/metrics/instance.d.ts.map +1 -1
- package/dist/metrics/instance.js +19 -0
- package/dist/metrics/instance.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/api/client.test.ts +66 -10
- package/src/api/client.ts +44 -7
- package/src/api/github-octokit.test.ts +115 -0
- package/src/api/github-octokit.ts +49 -0
- package/src/api/installation-token-envelope.ts +24 -2
- package/src/api/installation-token-provider.test.ts +44 -5
- package/src/api/installation-token-provider.ts +5 -2
- package/src/api/shared-installation-token-cache.test.ts +28 -0
- package/src/api/shared-installation-token-cache.ts +7 -0
- package/src/config.ts +5 -0
- package/src/core/agent-tools.test.ts +1049 -8
- package/src/core/agent-tools.ts +388 -25
- package/src/core/github-agent-tool-catalog.ts +1 -1
- package/src/metrics/instance.ts +25 -0
- package/test/env.ts +1 -0
- package/test/fixtures/github-installation-token.ts +8 -0
- package/test/index.ts +4 -0
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/agent-tools.ts"],"sourcesContent":["import type {\n AgentToolCallInput,\n AgentToolCatalogEntry,\n AgentToolSelectionCatalog,\n AgentToolSession,\n AgentToolsProvider,\n IntegrationConnection,\n OpenAgentToolsSessionInput,\n} from '@shipfox/api-integration-spi';\nimport {Octokit} from 'octokit';\nimport {\n createGithubInstallationTokenProvider,\n type GithubInstallationTokenProvider,\n} from '#api/installation-token-provider.js';\nimport {normalizedGithubApiBaseUrl} from '#config.js';\nimport type {GithubInstallation} from '#db/installations.js';\nimport {GithubIntegrationProviderError} from './errors.js';\nimport {\n type GithubAgentToolCatalogEntry,\n type GithubAgentToolId,\n type GithubAgentToolRequiredScope,\n githubAgentToolCatalog,\n githubAgentToolSelectionCatalog,\n} from './github-agent-tool-catalog.js';\n\nexport type {\n GithubAgentToolCatalogEntry,\n GithubAgentToolCategory,\n GithubAgentToolId,\n GithubAgentToolPermission,\n GithubAgentToolPermissionAccess,\n GithubAgentToolRequiredPermission,\n GithubAgentToolRequiredScope,\n GithubAgentToolSensitivity,\n} from './github-agent-tool-catalog.js';\nexport {\n buildGithubAgentToolSelectionCatalog,\n DEFAULT_JOB_LOG_TAIL_LINES,\n githubAgentToolCatalog,\n githubAgentToolSelectionCatalog,\n} from './github-agent-tool-catalog.js';\n\ntype GithubIntegrationConnection = IntegrationConnection<'github'>;\n\ntype GithubToolCallResult = {\n isError?: boolean | undefined;\n content: readonly {type: 'text'; text: string}[];\n structuredContent?: Record<string, unknown> | undefined;\n};\n\nexport class GithubAgentToolsProvider\n implements\n AgentToolsProvider<\n GithubIntegrationConnection,\n GithubAgentToolRequiredScope,\n unknown,\n GithubToolCallResult\n >\n{\n private readonly tokenProvider: GithubInstallationTokenProvider;\n\n constructor(private readonly options: GithubAgentToolsProviderOptions = {}) {\n this.tokenProvider = options.tokenProvider ?? createGithubInstallationTokenProvider();\n }\n\n catalog(): readonly GithubAgentToolCatalogEntry[] {\n return githubAgentToolCatalog;\n }\n\n selectionCatalog(): AgentToolSelectionCatalog {\n return githubAgentToolSelectionCatalog;\n }\n\n async openSession(\n input: OpenAgentToolsSessionInput<GithubIntegrationConnection, GithubAgentToolRequiredScope>,\n ): Promise<AgentToolSession<GithubToolCallResult>> {\n const installation = await this.options.getInstallationByConnectionId?.(input.connection.id);\n if (!installation) {\n throw new GithubIntegrationProviderError(\n 'installation-not-found',\n 'GitHub installation is not connected to this integration',\n );\n }\n const installationId = Number(installation.installationId);\n if (!Number.isSafeInteger(installationId) || installationId < 1) {\n throw new GithubIntegrationProviderError(\n 'malformed-provider-response',\n 'GitHub installation has an invalid installation ID',\n );\n }\n let tokenPromise:\n | ReturnType<GithubInstallationTokenProvider['getInstallationAccessToken']>\n | undefined;\n\n return {\n call: async (call) => {\n const tool = input.tools.find((candidate) => candidate.id === call.toolId);\n if (!tool) return githubToolError(`Unknown GitHub tool: ${call.toolId}`);\n const operation = resolveGithubOperation(tool, call);\n if (operation === undefined) return githubToolError('Unknown GitHub tool operation');\n const validationError = validateGithubToolArguments(tool, call.arguments);\n if (validationError) return githubToolError(validationError);\n tokenPromise ??= this.tokenProvider.getInstallationAccessToken(installationId);\n const token = await tokenPromise;\n if (!hasGrantedPermissions(token.permissions ?? {}, tool, call)) {\n return githubToolError(\n 'GitHub installation token is missing permission for this operation',\n );\n }\n const client = (this.options.createClient ?? createOctokitClient)(token.token);\n\n try {\n const response = await client.request(operation.route, operation.parameters);\n return githubToolResult(tool.id as GithubAgentToolId, response.data);\n } catch (error) {\n if (error instanceof GithubIntegrationProviderError)\n return githubToolError(error.message);\n throw error;\n }\n },\n };\n }\n}\n\nexport interface GithubAgentToolsProviderOptions {\n getInstallationByConnectionId?:\n | ((connectionId: string) => Promise<GithubInstallation | undefined>)\n | undefined;\n tokenProvider?: GithubInstallationTokenProvider | undefined;\n createClient?: GithubToolClientFactory | undefined;\n}\n\nexport interface GithubToolClient {\n request(route: string, parameters: Record<string, unknown>): Promise<{data: unknown}>;\n}\n\nexport type GithubToolClientFactory = (token: string) => GithubToolClient;\n\ninterface GithubToolOperation {\n route: string;\n parameters: Record<string, unknown>;\n}\n\nfunction createOctokitClient(token: string): GithubToolClient {\n const octokit = new Octokit({\n auth: token,\n baseUrl: normalizedGithubApiBaseUrl(),\n retry: {enabled: false},\n });\n return {\n request: async (route, parameters) => await octokit.request(route, parameters),\n };\n}\n\nfunction resolveGithubOperation(\n tool: AgentToolCatalogEntry<GithubAgentToolRequiredScope>,\n call: AgentToolCallInput,\n): GithubToolOperation | undefined {\n const args = call.arguments;\n const method = typeof args.method === 'string' ? args.method : undefined;\n const params = {...args};\n delete params.method;\n\n if (tool.methods && !tool.methods.some((candidate) => candidate.id === method)) return undefined;\n\n const toolId = tool.id as GithubAgentToolId;\n const route = githubOperationRoute(toolId, method, params);\n return route === undefined\n ? undefined\n : {route, parameters: projectGithubOperationParameters(toolId, method, params)};\n}\n\nfunction githubOperationRoute(\n toolId: GithubAgentToolId,\n method: string | undefined,\n args: Record<string, unknown>,\n): string | undefined {\n const owner = '{owner}';\n const repo = '{repo}';\n const issue = '{issue_number}';\n const pull = '{pull_number}';\n const run = '{run_id}';\n const resource = '{resource_id}';\n const repoPath = `/repos/${owner}/${repo}`;\n\n switch (`${toolId}.${method ?? ''}`) {\n case 'issue_read.get':\n return `GET ${repoPath}/issues/${issue}`;\n case 'issue_read.get_comments':\n return `GET ${repoPath}/issues/${issue}/comments`;\n case 'issue_read.get_sub_issues':\n return `GET ${repoPath}/issues/${issue}/sub_issues`;\n case 'issue_read.get_parent':\n return `GET ${repoPath}/issues/${issue}/parent`;\n case 'issue_read.get_labels':\n return `GET ${repoPath}/issues/${issue}/labels`;\n case 'list_issue_types.':\n return args.repo === undefined\n ? 'GET /orgs/{owner}/issue-types'\n : `GET ${repoPath}/issue-types`;\n case 'list_issues.':\n return `GET ${repoPath}/issues`;\n case 'search_issues.':\n return 'GET /search/issues';\n case 'add_issue_comment.':\n if (args.comment_id !== undefined)\n return `POST ${repoPath}/issues/comments/{comment_id}/reactions`;\n return args.reaction !== undefined && args.body === undefined\n ? `POST ${repoPath}/issues/${issue}/reactions`\n : `POST ${repoPath}/issues/${issue}/comments`;\n case 'issue_write.create':\n return `POST ${repoPath}/issues`;\n case 'issue_write.update':\n return `PATCH ${repoPath}/issues/${issue}`;\n case 'sub_issue_write.add':\n return `POST ${repoPath}/issues/${issue}/sub_issues`;\n case 'sub_issue_write.remove':\n return `DELETE ${repoPath}/issues/${issue}/sub_issues/{sub_issue_id}`;\n case 'sub_issue_write.reprioritize':\n return `PATCH ${repoPath}/issues/${issue}/sub_issues/{sub_issue_id}`;\n case 'pull_request_read.get':\n return `GET ${repoPath}/pulls/${pull}`;\n case 'pull_request_read.get_diff':\n return `GET ${repoPath}/pulls/${pull}`;\n case 'pull_request_read.get_status':\n return `GET ${repoPath}/commits/{ref}/status`;\n case 'pull_request_read.get_files':\n return `GET ${repoPath}/pulls/${pull}/files`;\n case 'pull_request_read.get_commits':\n return `GET ${repoPath}/pulls/${pull}/commits`;\n case 'pull_request_read.get_review_comments':\n return `GET ${repoPath}/pulls/${pull}/comments`;\n case 'pull_request_read.get_reviews':\n return `GET ${repoPath}/pulls/${pull}/reviews`;\n case 'pull_request_read.get_comments':\n return `GET ${repoPath}/issues/${pull}/comments`;\n case 'pull_request_read.get_check_runs':\n return `GET ${repoPath}/commits/{ref}/check-runs`;\n case 'list_pull_requests.':\n return `GET ${repoPath}/pulls`;\n case 'search_pull_requests.':\n return 'GET /search/issues';\n case 'create_pull_request.':\n return `POST ${repoPath}/pulls`;\n case 'update_pull_request.':\n return `PATCH ${repoPath}/pulls/${pull}`;\n case 'add_reply_to_pull_request_comment.':\n return `POST ${repoPath}/pulls/{comment_id}/replies`;\n case 'merge_pull_request.':\n return `PUT ${repoPath}/pulls/${pull}/merge`;\n case 'update_pull_request_branch.':\n return `PUT ${repoPath}/pulls/${pull}/update-branch`;\n case 'pull_request_review_write.create':\n return `POST ${repoPath}/pulls/${pull}/reviews`;\n case 'pull_request_review_write.submit_pending':\n return `POST ${repoPath}/pulls/${pull}/reviews/{review_id}/events`;\n case 'pull_request_review_write.delete_pending':\n return `DELETE ${repoPath}/pulls/${pull}/reviews/{review_id}`;\n case 'add_comment_to_pending_review.':\n return `POST ${repoPath}/pulls/${pull}/comments`;\n case 'actions_list.list_workflows':\n return `GET ${repoPath}/actions/workflows`;\n case 'actions_list.list_workflow_runs':\n return `GET ${repoPath}/actions/workflows/${resource}/runs`;\n case 'actions_list.list_workflow_jobs':\n return `GET ${repoPath}/actions/runs/${resource}/jobs`;\n case 'actions_list.list_workflow_run_artifacts':\n return `GET ${repoPath}/actions/runs/${resource}/artifacts`;\n case 'actions_get.get_workflow':\n return `GET ${repoPath}/actions/workflows/${resource}`;\n case 'actions_get.get_workflow_run':\n return `GET ${repoPath}/actions/runs/${resource}`;\n case 'actions_get.get_workflow_job':\n return `GET ${repoPath}/actions/jobs/${resource}`;\n case 'actions_get.download_workflow_run_artifact':\n return `GET ${repoPath}/actions/artifacts/${resource}/{archive_format}`;\n case 'actions_get.get_workflow_run_usage':\n return `GET ${repoPath}/actions/runs/${resource}/timing`;\n case 'actions_get.get_workflow_run_logs_url':\n return `GET ${repoPath}/actions/runs/${resource}/logs`;\n case 'actions_run_trigger.run_workflow':\n return `POST ${repoPath}/actions/workflows/{workflow_id}/dispatches`;\n case 'actions_run_trigger.rerun_workflow_run':\n return `POST ${repoPath}/actions/runs/${run}/rerun`;\n case 'actions_run_trigger.rerun_failed_jobs':\n return `POST ${repoPath}/actions/runs/${run}/rerun-failed-jobs`;\n case 'actions_run_trigger.cancel_workflow_run':\n return `POST ${repoPath}/actions/runs/${run}/cancel`;\n case 'actions_run_trigger.delete_workflow_run_logs':\n return `DELETE ${repoPath}/actions/runs/${run}/logs`;\n case 'get_job_logs.':\n return `GET ${repoPath}/actions/jobs/{job_id}/logs`;\n default:\n return undefined;\n }\n}\n\nfunction projectGithubOperationParameters(\n toolId: GithubAgentToolId,\n method: string | undefined,\n args: Record<string, unknown>,\n): Record<string, unknown> {\n const parameters = {...args};\n if (toolId === 'add_issue_comment' && parameters.reaction !== undefined) {\n parameters.content = parameters.reaction;\n delete parameters.reaction;\n if (parameters.body === undefined) delete parameters.body;\n }\n if (toolId === 'pull_request_read' && method === 'get_diff') {\n parameters.headers = {accept: 'application/vnd.github.diff'};\n }\n return parameters;\n}\n\nfunction githubToolResult(toolId: GithubAgentToolId, data: unknown): GithubToolCallResult {\n const structuredContent = projectGithubToolOutput(toolId, data);\n return {\n content: [{type: 'text', text: JSON.stringify(structuredContent)}],\n structuredContent,\n };\n}\n\nfunction projectGithubToolOutput(\n toolId: GithubAgentToolId,\n data: unknown,\n): Record<string, unknown> {\n switch (toolId) {\n case 'list_issue_types':\n return {issue_types: data};\n case 'list_issues':\n return {issues: data};\n case 'search_issues':\n return {issues: githubSearchItems(data)};\n case 'list_pull_requests':\n return {pull_requests: data};\n case 'search_pull_requests':\n return {pull_requests: githubSearchItems(data)};\n case 'create_pull_request':\n case 'update_pull_request':\n return {pull_request: data};\n case 'merge_pull_request':\n return {merge: data};\n default:\n return isRecord(data) ? data : {result: data};\n }\n}\n\nfunction githubSearchItems(data: unknown): unknown {\n return isRecord(data) ? data.items : data;\n}\n\nfunction githubToolError(message: string): GithubToolCallResult {\n return {isError: true, content: [{type: 'text', text: message}]};\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction validateGithubToolArguments(\n tool: AgentToolCatalogEntry<GithubAgentToolRequiredScope>,\n arguments_: Record<string, unknown>,\n): string | undefined {\n const required = Array.isArray(tool.inputSchema.required) ? tool.inputSchema.required : [];\n for (const name of required) {\n if (typeof name === 'string' && arguments_[name] === undefined) {\n return `Missing required parameter: ${name}`;\n }\n }\n\n const methodRequired = methodRequiredParameters(tool.inputSchema, arguments_);\n for (const name of methodRequired) {\n if (arguments_[name] === undefined) return `Missing required parameter: ${name}`;\n }\n\n const properties = tool.inputSchema.properties;\n if (typeof properties !== 'object' || properties === null || Array.isArray(properties)) {\n return undefined;\n }\n const propertySchemas = properties as Record<string, unknown>;\n for (const [name, value] of Object.entries(arguments_)) {\n const schema = propertySchemas[name];\n if (typeof schema !== 'object' || schema === null || Array.isArray(schema)) continue;\n const type = (schema as {type?: unknown}).type;\n if (type === 'integer' && (!Number.isInteger(value) || typeof value !== 'number')) {\n return `Parameter ${name} must be an integer`;\n }\n if (type === 'array' && !Array.isArray(value)) return `Parameter ${name} must be an array`;\n }\n return undefined;\n}\n\nfunction methodRequiredParameters(\n inputSchema: AgentToolCatalogEntry<GithubAgentToolRequiredScope>['inputSchema'],\n arguments_: Record<string, unknown>,\n): string[] {\n const method = arguments_.method;\n if (typeof method !== 'string' || !Array.isArray(inputSchema.oneOf)) return [];\n\n for (const candidate of inputSchema.oneOf) {\n if (!isRecord(candidate) || !isRecord(candidate.properties)) continue;\n const methodSchema = candidate.properties.method;\n if (!isRecord(methodSchema) || methodSchema.const !== method) continue;\n return Array.isArray(candidate.required)\n ? candidate.required.filter((name): name is string => typeof name === 'string')\n : [];\n }\n\n return [];\n}\n\nfunction hasGrantedPermissions(\n granted: Record<string, 'read' | 'write' | 'admin'>,\n tool: AgentToolCatalogEntry<GithubAgentToolRequiredScope>,\n call: AgentToolCallInput,\n): boolean {\n const method = typeof call.arguments.method === 'string' ? call.arguments.method : undefined;\n const required =\n tool.methods?.find((candidate) => candidate.id === method)?.requiredScope ?? tool.requiredScope;\n return required.every(({permission, access}) => {\n const actual = granted[permission];\n return actual === 'write' || actual === 'admin' || actual === access;\n });\n}\n"],"names":["Octokit","createGithubInstallationTokenProvider","normalizedGithubApiBaseUrl","GithubIntegrationProviderError","githubAgentToolCatalog","githubAgentToolSelectionCatalog","buildGithubAgentToolSelectionCatalog","DEFAULT_JOB_LOG_TAIL_LINES","GithubAgentToolsProvider","options","tokenProvider","catalog","selectionCatalog","openSession","input","installation","getInstallationByConnectionId","connection","id","installationId","Number","isSafeInteger","tokenPromise","call","tool","tools","find","candidate","toolId","githubToolError","operation","resolveGithubOperation","undefined","validationError","validateGithubToolArguments","arguments","getInstallationAccessToken","token","hasGrantedPermissions","permissions","client","createClient","createOctokitClient","response","request","route","parameters","githubToolResult","data","error","message","octokit","auth","baseUrl","retry","enabled","args","method","params","methods","some","githubOperationRoute","projectGithubOperationParameters","owner","repo","issue","pull","run","resource","repoPath","comment_id","reaction","body","content","headers","accept","structuredContent","projectGithubToolOutput","type","text","JSON","stringify","issue_types","issues","githubSearchItems","pull_requests","pull_request","merge","isRecord","result","items","isError","value","Array","isArray","arguments_","required","inputSchema","name","methodRequired","methodRequiredParameters","properties","propertySchemas","Object","entries","schema","isInteger","oneOf","methodSchema","const","filter","granted","requiredScope","every","permission","access","actual"],"mappings":"AASA,SAAQA,OAAO,QAAO,UAAU;AAChC,SACEC,qCAAqC,QAEhC,sCAAsC;AAC7C,SAAQC,0BAA0B,QAAO,aAAa;AAEtD,SAAQC,8BAA8B,QAAO,cAAc;AAC3D,SAIEC,sBAAsB,EACtBC,+BAA+B,QAC1B,iCAAiC;AAYxC,SACEC,oCAAoC,EACpCC,0BAA0B,EAC1BH,sBAAsB,EACtBC,+BAA+B,QAC1B,iCAAiC;AAUxC,OAAO,MAAMG;IAWX,YAAY,AAAiBC,UAA2C,CAAC,CAAC,CAAE;aAA/CA,UAAAA;QAC3B,IAAI,CAACC,aAAa,GAAGD,QAAQC,aAAa,IAAIT;IA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MC,SAASL,OAAO,CAACG,WAAW;QAClC,OAAOE,WAAW,WAAWA,WAAW,WAAWA,WAAWD;IAChE;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/core/agent-tools.ts"],"sourcesContent":["import type {\n AgentToolCallInput,\n AgentToolCatalogEntry,\n AgentToolSelectionCatalog,\n AgentToolSession,\n AgentToolsProvider,\n IntegrationConnection,\n OpenAgentToolsSessionInput,\n} from '@shipfox/api-integration-spi';\nimport {Octokit} from 'octokit';\nimport {mapGithubError} from '#api/client.js';\nimport {\n createGithubInstallationTokenProvider,\n type GithubInstallationTokenProvider,\n} from '#api/installation-token-provider.js';\nimport {config, normalizedGithubApiBaseUrl} from '#config.js';\nimport type {GithubInstallation} from '#db/installations.js';\nimport {GithubIntegrationProviderError} from './errors.js';\nimport {\n type GithubAgentToolCatalogEntry,\n type GithubAgentToolId,\n type GithubAgentToolRequiredScope,\n githubAgentToolCatalog,\n githubAgentToolSelectionCatalog,\n} from './github-agent-tool-catalog.js';\n\nexport type {\n GithubAgentToolCatalogEntry,\n GithubAgentToolCategory,\n GithubAgentToolId,\n GithubAgentToolPermission,\n GithubAgentToolPermissionAccess,\n GithubAgentToolRequiredPermission,\n GithubAgentToolRequiredScope,\n GithubAgentToolSensitivity,\n} from './github-agent-tool-catalog.js';\nexport {\n buildGithubAgentToolSelectionCatalog,\n DEFAULT_JOB_LOG_TAIL_LINES,\n githubAgentToolCatalog,\n githubAgentToolSelectionCatalog,\n} from './github-agent-tool-catalog.js';\n\ntype GithubIntegrationConnection = IntegrationConnection<'github'>;\n\ntype GithubToolCallResult = {\n isError?: boolean | undefined;\n content: readonly {type: 'text'; text: string}[];\n structuredContent?: Record<string, unknown> | undefined;\n};\n\ntype GithubToolErrorCode =\n | 'invalid-request'\n | 'access-denied'\n | 'provider-rejected'\n | 'malformed-provider-response';\n\nconst GITHUB_GRAPHQL_ROUTE = 'POST /graphql';\nconst GITHUB_ARTIFACT_ARCHIVE_FORMAT = 'zip';\nconst GITHUB_ARTIFACT_DOWNLOAD_ROUTE = `GET /repos/{owner}/{repo}/actions/artifacts/{resource_id}/${GITHUB_ARTIFACT_ARCHIVE_FORMAT}`;\nconst GITHUB_ARTIFACT_DOWNLOAD_TIMEOUT_MS = 30_000;\nconst GITHUB_APP_BOT_SUFFIX = '[bot]';\nconst PENDING_REVIEW_PAGE_SIZE = 100;\nconst PENDING_REVIEW_MAX_PAGE_REQUESTS = 5;\nconst PENDING_REVIEW_LOOKUP_TIMEOUT_MS = 15_000;\nconst PENDING_REVIEW_PAGE_TIMEOUT_MS = 5_000;\nconst PENDING_REVIEW_PAGE_PATTERN = /[?&]page=(\\d+)/u;\nconst NO_PENDING_REVIEW_MESSAGE =\n 'No pending pull request review found for the authenticated GitHub user.';\n\nconst ADD_PENDING_REVIEW_COMMENT_MUTATION = `\n mutation AddCommentToPendingReview($input: AddPullRequestReviewThreadInput!) {\n addPullRequestReviewThread(input: $input) {\n thread {\n id\n }\n }\n }\n`;\n\nexport class GithubAgentToolsProvider\n implements\n AgentToolsProvider<\n GithubIntegrationConnection,\n GithubAgentToolRequiredScope,\n unknown,\n GithubToolCallResult\n >\n{\n private readonly tokenProvider: GithubInstallationTokenProvider;\n\n constructor(private readonly options: GithubAgentToolsProviderOptions = {}) {\n this.tokenProvider = options.tokenProvider ?? createGithubInstallationTokenProvider();\n }\n\n catalog(): readonly GithubAgentToolCatalogEntry[] {\n return githubAgentToolCatalog;\n }\n\n selectionCatalog(): AgentToolSelectionCatalog {\n return githubAgentToolSelectionCatalog;\n }\n\n async openSession(\n input: OpenAgentToolsSessionInput<GithubIntegrationConnection, GithubAgentToolRequiredScope>,\n ): Promise<AgentToolSession<GithubToolCallResult>> {\n const installation = await this.options.getInstallationByConnectionId?.(input.connection.id);\n if (!installation) {\n throw new GithubIntegrationProviderError(\n 'installation-not-found',\n 'GitHub installation is not connected to this integration',\n );\n }\n const installationId = Number(installation.installationId);\n if (!Number.isSafeInteger(installationId) || installationId < 1) {\n throw new GithubIntegrationProviderError(\n 'malformed-provider-response',\n 'GitHub installation has an invalid installation ID',\n );\n }\n let tokenPromise:\n | ReturnType<GithubInstallationTokenProvider['getInstallationAccessToken']>\n | undefined;\n\n return {\n call: async (call) => {\n const tool = input.tools.find((candidate) => candidate.id === call.toolId);\n if (!tool) return githubToolError(`Unknown GitHub tool: ${call.toolId}`, 'invalid-request');\n const operation = resolveGithubOperation(tool, call);\n if (operation === undefined)\n return githubToolError('Unknown GitHub tool operation', 'invalid-request');\n const validationError = validateGithubToolArguments(tool, call.arguments);\n if (validationError) return githubToolError(validationError, 'invalid-request');\n tokenPromise ??= this.tokenProvider.getInstallationAccessToken(installationId);\n const token = await tokenPromise;\n if (!hasGrantedPermissions(token.permissions ?? {}, tool, call)) {\n return githubToolError(\n 'GitHub installation token is missing permission for this operation',\n 'access-denied',\n );\n }\n const client = (this.options.createClient ?? createOctokitClient)(token.token);\n const method =\n typeof call.arguments.method === 'string' ? call.arguments.method : undefined;\n\n if (operation.kind === 'graphql') {\n const data = await mapGithubError(() =>\n addCommentToPendingReview(client, operation.parameters),\n );\n return data === undefined\n ? githubToolError(NO_PENDING_REVIEW_MESSAGE, 'provider-rejected')\n : githubToolResult(tool.id as GithubAgentToolId, data);\n }\n\n const operationParameters = await mapGithubError(() =>\n resolvePendingReviewParameters(\n client,\n operation.parameters,\n tool.id as GithubAgentToolId,\n method,\n ),\n );\n if (operationParameters === undefined) {\n return githubToolError(NO_PENDING_REVIEW_MESSAGE, 'provider-rejected');\n }\n const response = await mapGithubError(() =>\n client.request(operation.route, operationParameters),\n );\n return githubToolResult(\n tool.id as GithubAgentToolId,\n response.data,\n response,\n operationParameters,\n operation.route,\n );\n },\n };\n }\n}\n\nexport interface GithubAgentToolsProviderOptions {\n getInstallationByConnectionId?:\n | ((connectionId: string) => Promise<GithubInstallation | undefined>)\n | undefined;\n tokenProvider?: GithubInstallationTokenProvider | undefined;\n createClient?: GithubToolClientFactory | undefined;\n}\n\nexport interface GithubToolResponse {\n data: unknown;\n headers?: Record<string, string | number | undefined> | undefined;\n status?: number | undefined;\n url?: string | undefined;\n}\n\nexport interface GithubToolClient {\n request(route: string, parameters: Record<string, unknown>): Promise<GithubToolResponse>;\n graphql?: ((query: string, variables: Record<string, unknown>) => Promise<unknown>) | undefined;\n}\n\nexport type GithubToolClientFactory = (token: string) => GithubToolClient;\n\ninterface GithubToolOperation {\n route: string;\n parameters: Record<string, unknown>;\n kind: 'rest' | 'graphql';\n}\n\nfunction createOctokitClient(token: string): GithubToolClient {\n const octokit = new Octokit({\n auth: token,\n baseUrl: normalizedGithubApiBaseUrl(),\n retry: {enabled: false},\n });\n return {\n request: async (route, parameters) => {\n if (route !== GITHUB_ARTIFACT_DOWNLOAD_ROUTE) {\n return await octokit.request(route, parameters);\n }\n\n const abortController = new AbortController();\n const timeout = setTimeout(\n () => abortController.abort(),\n GITHUB_ARTIFACT_DOWNLOAD_TIMEOUT_MS,\n );\n try {\n return await octokit.request(route, {\n ...parameters,\n request: {\n redirect: 'manual',\n parseSuccessResponseBody: false,\n signal: abortController.signal,\n },\n });\n } finally {\n clearTimeout(timeout);\n }\n },\n graphql: async (query, variables) => await octokit.graphql(query, variables),\n };\n}\n\nfunction resolveGithubOperation(\n tool: AgentToolCatalogEntry<GithubAgentToolRequiredScope>,\n call: AgentToolCallInput,\n): GithubToolOperation | undefined {\n const args = call.arguments;\n const method = typeof args.method === 'string' ? args.method : undefined;\n const params = {...args};\n delete params.method;\n\n if (tool.methods && !tool.methods.some((candidate) => candidate.id === method)) return undefined;\n\n const toolId = tool.id as GithubAgentToolId;\n const route = githubOperationRoute(toolId, method, params);\n return route === undefined\n ? undefined\n : {\n route,\n parameters: projectGithubOperationParameters(toolId, method, params),\n kind: route === GITHUB_GRAPHQL_ROUTE ? 'graphql' : 'rest',\n };\n}\n\nexport function githubOperationRoute(\n toolId: GithubAgentToolId,\n method: string | undefined,\n args: Record<string, unknown>,\n): string | undefined {\n const owner = '{owner}';\n const repo = '{repo}';\n const issue = '{issue_number}';\n const pull = '{pull_number}';\n const run = '{run_id}';\n const resource = '{resource_id}';\n const repoPath = `/repos/${owner}/${repo}`;\n\n switch (`${toolId}.${method ?? ''}`) {\n case 'issue_read.get':\n return `GET ${repoPath}/issues/${issue}`;\n case 'issue_read.get_comments':\n return `GET ${repoPath}/issues/${issue}/comments`;\n case 'issue_read.get_sub_issues':\n return `GET ${repoPath}/issues/${issue}/sub_issues`;\n case 'issue_read.get_parent':\n return `GET ${repoPath}/issues/${issue}/parent`;\n case 'issue_read.get_labels':\n return `GET ${repoPath}/issues/${issue}/labels`;\n case 'list_issue_types.':\n return args.repo === undefined\n ? 'GET /orgs/{owner}/issue-types'\n : `GET ${repoPath}/issue-types`;\n case 'list_issues.':\n return `GET ${repoPath}/issues`;\n case 'search_issues.':\n return 'GET /search/issues';\n case 'add_issue_comment.':\n if (args.comment_id !== undefined)\n return `POST ${repoPath}/issues/comments/{comment_id}/reactions`;\n return args.reaction !== undefined && args.body === undefined\n ? `POST ${repoPath}/issues/${issue}/reactions`\n : `POST ${repoPath}/issues/${issue}/comments`;\n case 'issue_write.create':\n return `POST ${repoPath}/issues`;\n case 'issue_write.update':\n return `PATCH ${repoPath}/issues/${issue}`;\n case 'sub_issue_write.add':\n return `POST ${repoPath}/issues/${issue}/sub_issues`;\n case 'sub_issue_write.remove':\n return `DELETE ${repoPath}/issues/${issue}/sub_issues/{sub_issue_id}`;\n case 'sub_issue_write.reprioritize':\n return `PATCH ${repoPath}/issues/${issue}/sub_issues/priority`;\n case 'pull_request_read.get':\n return `GET ${repoPath}/pulls/${pull}`;\n case 'pull_request_read.get_diff':\n return `GET ${repoPath}/pulls/${pull}`;\n case 'pull_request_read.get_status':\n return `GET ${repoPath}/commits/{ref}/status`;\n case 'pull_request_read.get_files':\n return `GET ${repoPath}/pulls/${pull}/files`;\n case 'pull_request_read.get_commits':\n return `GET ${repoPath}/pulls/${pull}/commits`;\n case 'pull_request_read.get_review_comments':\n return `GET ${repoPath}/pulls/${pull}/comments`;\n case 'pull_request_read.get_reviews':\n return `GET ${repoPath}/pulls/${pull}/reviews`;\n case 'pull_request_read.get_comments':\n return `GET ${repoPath}/issues/${pull}/comments`;\n case 'pull_request_read.get_check_runs':\n return `GET ${repoPath}/commits/{ref}/check-runs`;\n case 'list_pull_requests.':\n return `GET ${repoPath}/pulls`;\n case 'search_pull_requests.':\n return 'GET /search/issues';\n case 'create_pull_request.':\n return `POST ${repoPath}/pulls`;\n case 'update_pull_request.':\n return `PATCH ${repoPath}/pulls/${pull}`;\n case 'add_reply_to_pull_request_comment.':\n return args.reaction !== undefined && args.body === undefined\n ? `POST ${repoPath}/pulls/comments/{comment_id}/reactions`\n : `POST ${repoPath}/pulls/${pull}/comments/{comment_id}/replies`;\n case 'merge_pull_request.':\n return `PUT ${repoPath}/pulls/${pull}/merge`;\n case 'update_pull_request_branch.':\n return `PUT ${repoPath}/pulls/${pull}/update-branch`;\n case 'pull_request_review_write.create':\n return `POST ${repoPath}/pulls/${pull}/reviews`;\n case 'pull_request_review_write.submit_pending':\n return `POST ${repoPath}/pulls/${pull}/reviews/{review_id}/events`;\n case 'pull_request_review_write.delete_pending':\n return `DELETE ${repoPath}/pulls/${pull}/reviews/{review_id}`;\n case 'add_comment_to_pending_review.':\n return GITHUB_GRAPHQL_ROUTE;\n case 'actions_list.list_workflows':\n return `GET ${repoPath}/actions/workflows`;\n case 'actions_list.list_workflow_runs':\n return `GET ${repoPath}/actions/workflows/${resource}/runs`;\n case 'actions_list.list_workflow_jobs':\n return `GET ${repoPath}/actions/runs/${resource}/jobs`;\n case 'actions_list.list_workflow_run_artifacts':\n return `GET ${repoPath}/actions/runs/${resource}/artifacts`;\n case 'actions_get.get_workflow':\n return `GET ${repoPath}/actions/workflows/${resource}`;\n case 'actions_get.get_workflow_run':\n return `GET ${repoPath}/actions/runs/${resource}`;\n case 'actions_get.get_workflow_job':\n return `GET ${repoPath}/actions/jobs/${resource}`;\n case 'actions_get.download_workflow_run_artifact':\n return GITHUB_ARTIFACT_DOWNLOAD_ROUTE;\n case 'actions_get.get_workflow_run_usage':\n return `GET ${repoPath}/actions/runs/${resource}/timing`;\n case 'actions_get.get_workflow_run_logs_url':\n return `GET ${repoPath}/actions/runs/${resource}/logs`;\n case 'actions_run_trigger.run_workflow':\n return `POST ${repoPath}/actions/workflows/{workflow_id}/dispatches`;\n case 'actions_run_trigger.rerun_workflow_run':\n return `POST ${repoPath}/actions/runs/${run}/rerun`;\n case 'actions_run_trigger.rerun_failed_jobs':\n return `POST ${repoPath}/actions/runs/${run}/rerun-failed-jobs`;\n case 'actions_run_trigger.cancel_workflow_run':\n return `POST ${repoPath}/actions/runs/${run}/cancel`;\n case 'actions_run_trigger.delete_workflow_run_logs':\n return `DELETE ${repoPath}/actions/runs/${run}/logs`;\n case 'get_job_logs.':\n return `GET ${repoPath}/actions/jobs/{job_id}/logs`;\n default:\n return undefined;\n }\n}\n\nasync function addCommentToPendingReview(\n client: GithubToolClient,\n args: Record<string, unknown>,\n): Promise<unknown | undefined> {\n if (client.graphql === undefined) {\n throw new GithubIntegrationProviderError(\n 'malformed-provider-response',\n 'GitHub client does not support GraphQL operations',\n );\n }\n\n const review = await latestPendingReview(client, args, 'nodeId');\n if (review === undefined) return undefined;\n if (review.nodeId === undefined) {\n throw new GithubIntegrationProviderError(\n 'malformed-provider-response',\n 'GitHub pending pull request review did not include a node ID',\n );\n }\n\n const input: Record<string, unknown> = {\n pullRequestReviewId: review.nodeId,\n path: args.path,\n body: args.body,\n subjectType: args.subject_type,\n };\n if (args.line !== undefined) input.line = args.line;\n if (args.side !== undefined) input.side = args.side;\n if (args.start_line !== undefined) input.startLine = args.start_line;\n if (args.start_side !== undefined) input.startSide = args.start_side;\n\n return await client.graphql(ADD_PENDING_REVIEW_COMMENT_MUTATION, {input});\n}\n\nexport function projectGithubOperationParameters(\n toolId: GithubAgentToolId,\n method: string | undefined,\n args: Record<string, unknown>,\n): Record<string, unknown> {\n const parameters = {...args};\n if (toolId === 'add_issue_comment' && parameters.reaction !== undefined) {\n parameters.content = parameters.reaction;\n delete parameters.reaction;\n if (parameters.body === undefined) delete parameters.body;\n }\n if (toolId === 'pull_request_read' && method === 'get_diff') {\n parameters.headers = {accept: 'application/vnd.github.diff'};\n }\n return parameters;\n}\n\nasync function resolvePendingReviewParameters(\n client: GithubToolClient,\n parameters: Record<string, unknown>,\n toolId: GithubAgentToolId,\n method: string | undefined,\n): Promise<Record<string, unknown> | undefined> {\n if (!isPendingReviewOperation(toolId, method)) return parameters;\n\n const review = await latestPendingReview(client, parameters, 'id');\n if (review === undefined) return undefined;\n if (review.id === undefined) {\n throw new GithubIntegrationProviderError(\n 'malformed-provider-response',\n 'GitHub pending pull request review did not include a numeric ID',\n );\n }\n return {...parameters, review_id: review.id};\n}\n\nfunction isPendingReviewOperation(toolId: GithubAgentToolId, method: string | undefined): boolean {\n return (\n toolId === 'pull_request_review_write' &&\n (method === 'submit_pending' || method === 'delete_pending')\n );\n}\n\ninterface PendingReviewReference {\n id?: number | undefined;\n nodeId?: string | undefined;\n}\n\ntype PendingReviewIdentifier = keyof PendingReviewReference;\n\ninterface PendingReviewPageResult {\n malformed: boolean;\n review?: PendingReviewReference | undefined;\n}\n\nasync function latestPendingReview(\n client: GithubToolClient,\n parameters: Record<string, unknown>,\n requiredIdentifier: PendingReviewIdentifier,\n): Promise<PendingReviewReference | undefined> {\n const lookupController = new AbortController();\n const lookupTimeout = setTimeout(\n () => lookupController.abort(),\n PENDING_REVIEW_LOOKUP_TIMEOUT_MS,\n );\n\n try {\n return await latestPendingReviewBeforeDeadline(\n client,\n parameters,\n requiredIdentifier,\n lookupController.signal,\n );\n } finally {\n clearTimeout(lookupTimeout);\n }\n}\n\nasync function latestPendingReviewBeforeDeadline(\n client: GithubToolClient,\n parameters: Record<string, unknown>,\n requiredIdentifier: PendingReviewIdentifier,\n lookupSignal: AbortSignal,\n): Promise<PendingReviewReference | undefined> {\n const firstPage = await requestPendingReviewPage(client, parameters, 1, lookupSignal);\n const lastPage = pendingReviewLastPage(firstPage.headers);\n let requests = 1;\n let malformed = false;\n\n for (let page = lastPage; page >= 1; page -= 1) {\n let response = firstPage;\n if (page !== 1) {\n if (requests >= PENDING_REVIEW_MAX_PAGE_REQUESTS) {\n throw new GithubIntegrationProviderError(\n 'content-too-large',\n 'GitHub pull request review history exceeded the pending review lookup limit',\n );\n }\n response = await requestPendingReviewPage(client, parameters, page, lookupSignal);\n requests += 1;\n }\n if (!Array.isArray(response.data)) {\n throw new GithubIntegrationProviderError(\n 'malformed-provider-response',\n 'GitHub pull request review list response was malformed',\n );\n }\n\n const result = latestPendingReviewOnPage(response.data, requiredIdentifier);\n if (result.review !== undefined) return result.review;\n malformed ||= result.malformed;\n }\n\n if (malformed) {\n throw new GithubIntegrationProviderError(\n 'malformed-provider-response',\n requiredIdentifier === 'nodeId'\n ? 'GitHub pending pull request review did not include a node ID'\n : 'GitHub pending pull request review did not include a numeric ID',\n );\n }\n return undefined;\n}\n\nasync function requestPendingReviewPage(\n client: GithubToolClient,\n parameters: Record<string, unknown>,\n page: number,\n lookupSignal: AbortSignal,\n): Promise<GithubToolResponse> {\n const pageController = new AbortController();\n const abortPage = () => pageController.abort();\n if (lookupSignal.aborted) abortPage();\n else lookupSignal.addEventListener('abort', abortPage, {once: true});\n const pageTimeout = setTimeout(abortPage, PENDING_REVIEW_PAGE_TIMEOUT_MS);\n\n try {\n return await client.request('GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews', {\n owner: parameters.owner,\n repo: parameters.repo,\n pull_number: parameters.pull_number,\n per_page: PENDING_REVIEW_PAGE_SIZE,\n page,\n request: {signal: pageController.signal},\n });\n } finally {\n clearTimeout(pageTimeout);\n lookupSignal.removeEventListener('abort', abortPage);\n }\n}\n\nfunction pendingReviewLastPage(headers: GithubToolResponse['headers']): number {\n const link = headers?.link;\n if (typeof link !== 'string') return 1;\n const lastLink = link.split(',').find((part) => part.includes('rel=\"last\"'));\n if (lastLink === undefined) return 1;\n const match = PENDING_REVIEW_PAGE_PATTERN.exec(lastLink);\n const page = match?.[1] === undefined ? Number.NaN : Number.parseInt(match[1], 10);\n if (!Number.isSafeInteger(page) || page < 1) {\n throw new GithubIntegrationProviderError(\n 'malformed-provider-response',\n 'GitHub pull request review pagination response was malformed',\n );\n }\n return page;\n}\n\nfunction latestPendingReviewOnPage(\n data: readonly unknown[],\n requiredIdentifier: PendingReviewIdentifier,\n): PendingReviewPageResult {\n let malformed = false;\n const appLogin = githubAppBotLogin().toLowerCase();\n for (let index = data.length - 1; index >= 0; index -= 1) {\n const review = data[index];\n if (!isRecord(review) || review.state !== 'PENDING') continue;\n const userLogin = isRecord(review.user) ? review.user.login : undefined;\n if (typeof userLogin !== 'string' || userLogin.trim().length === 0) {\n malformed = true;\n continue;\n }\n if (userLogin.trim().toLowerCase() !== appLogin) continue;\n const id =\n typeof review.id === 'number' && Number.isSafeInteger(review.id) && review.id > 0\n ? review.id\n : undefined;\n const nodeId =\n typeof review.node_id === 'string' && review.node_id.trim().length > 0\n ? review.node_id.trim()\n : undefined;\n const reference = {id, nodeId};\n if (reference[requiredIdentifier] !== undefined) return {malformed, review: reference};\n malformed = true;\n }\n\n return {malformed};\n}\n\nfunction githubAppBotLogin(): string {\n const configuredUsername = config.GITHUB_APP_USERNAME?.trim() || config.GITHUB_APP_SLUG.trim();\n return configuredUsername.toLowerCase().endsWith(GITHUB_APP_BOT_SUFFIX)\n ? configuredUsername\n : `${configuredUsername}${GITHUB_APP_BOT_SUFFIX}`;\n}\n\nfunction githubToolResult(\n toolId: GithubAgentToolId,\n data: unknown,\n response?: GithubToolResponse,\n parameters?: Record<string, unknown>,\n route?: string,\n): GithubToolCallResult {\n const structuredContent = projectGithubToolOutput(toolId, data, response, parameters, route);\n if (structuredContent === undefined) {\n return githubToolError(\n 'GitHub artifact download did not return a download URL',\n 'malformed-provider-response',\n );\n }\n return {\n content: [{type: 'text', text: JSON.stringify(structuredContent)}],\n structuredContent,\n };\n}\n\nfunction projectGithubToolOutput(\n toolId: GithubAgentToolId,\n data: unknown,\n response?: GithubToolResponse,\n parameters?: Record<string, unknown>,\n route?: string,\n): Record<string, unknown> | undefined {\n if (route === GITHUB_ARTIFACT_DOWNLOAD_ROUTE) {\n return projectGithubArtifactDownloadOutput(response, parameters);\n }\n\n switch (toolId) {\n case 'list_issue_types':\n return {issue_types: data};\n case 'list_issues':\n return {issues: data};\n case 'search_issues':\n return {issues: githubSearchItems(data)};\n case 'list_pull_requests':\n return {pull_requests: data};\n case 'search_pull_requests':\n return {pull_requests: githubSearchItems(data)};\n case 'create_pull_request':\n case 'update_pull_request':\n return {pull_request: data};\n case 'merge_pull_request':\n return {merge: data};\n default:\n return isRecord(data) ? data : {result: data};\n }\n}\n\nfunction projectGithubArtifactDownloadOutput(\n response: GithubToolResponse | undefined,\n parameters: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n if (response === undefined) return undefined;\n const downloadUrl = response.headers?.location;\n if (typeof downloadUrl !== 'string' || downloadUrl.length === 0) return undefined;\n\n const output: Record<string, unknown> = {\n archive_format: GITHUB_ARTIFACT_ARCHIVE_FORMAT,\n download_url: downloadUrl,\n };\n if (typeof parameters?.resource_id === 'string') output.artifact_id = parameters.resource_id;\n\n const contentType = response.headers?.['content-type'];\n if (typeof contentType === 'string') output.content_type = contentType;\n\n const contentLength = response.headers?.['content-length'];\n const sizeBytes = typeof contentLength === 'number' ? contentLength : Number(contentLength);\n if (Number.isSafeInteger(sizeBytes) && sizeBytes >= 0) output.size_bytes = sizeBytes;\n\n return output;\n}\n\nfunction githubSearchItems(data: unknown): unknown {\n return isRecord(data) ? data.items : data;\n}\n\nfunction githubToolError(message: string, code: GithubToolErrorCode): GithubToolCallResult {\n return {\n isError: true,\n content: [{type: 'text', text: message}],\n structuredContent: {code},\n };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction validateGithubToolArguments(\n tool: AgentToolCatalogEntry<GithubAgentToolRequiredScope>,\n arguments_: Record<string, unknown>,\n): string | undefined {\n const required = Array.isArray(tool.inputSchema.required) ? tool.inputSchema.required : [];\n for (const name of required) {\n if (typeof name === 'string' && arguments_[name] === undefined) {\n return `Missing required parameter: ${name}`;\n }\n }\n\n const methodRequired = methodRequiredParameters(tool.inputSchema, arguments_);\n for (const name of methodRequired) {\n if (arguments_[name] === undefined) return `Missing required parameter: ${name}`;\n }\n\n const properties = tool.inputSchema.properties;\n if (typeof properties !== 'object' || properties === null || Array.isArray(properties)) {\n return undefined;\n }\n const propertySchemas = properties as Record<string, unknown>;\n for (const [name, value] of Object.entries(arguments_)) {\n const schema = propertySchemas[name];\n if (typeof schema !== 'object' || schema === null || Array.isArray(schema)) continue;\n const type = (schema as {type?: unknown}).type;\n if (type === 'integer' && (!Number.isInteger(value) || typeof value !== 'number')) {\n return `Parameter ${name} must be an integer`;\n }\n if (type === 'array' && !Array.isArray(value)) return `Parameter ${name} must be an array`;\n }\n return undefined;\n}\n\nfunction methodRequiredParameters(\n inputSchema: AgentToolCatalogEntry<GithubAgentToolRequiredScope>['inputSchema'],\n arguments_: Record<string, unknown>,\n): string[] {\n const method = arguments_.method;\n if (typeof method !== 'string' || !Array.isArray(inputSchema.oneOf)) return [];\n\n for (const candidate of inputSchema.oneOf) {\n if (!isRecord(candidate) || !isRecord(candidate.properties)) continue;\n const methodSchema = candidate.properties.method;\n if (!isRecord(methodSchema) || methodSchema.const !== method) continue;\n return Array.isArray(candidate.required)\n ? candidate.required.filter((name): name is string => typeof name === 'string')\n : [];\n }\n\n return [];\n}\n\nfunction hasGrantedPermissions(\n granted: Record<string, 'read' | 'write' | 'admin'>,\n tool: AgentToolCatalogEntry<GithubAgentToolRequiredScope>,\n call: AgentToolCallInput,\n): boolean {\n const method = typeof call.arguments.method === 'string' ? call.arguments.method : undefined;\n const required =\n tool.methods?.find((candidate) => candidate.id === method)?.requiredScope ?? tool.requiredScope;\n return required.every(({permission, access}) => {\n const actual = granted[permission];\n return actual === 'write' || actual === 'admin' || actual === access;\n });\n}\n"],"names":["Octokit","mapGithubError","createGithubInstallationTokenProvider","config","normalizedGithubApiBaseUrl","GithubIntegrationProviderError","githubAgentToolCatalog","githubAgentToolSelectionCatalog","buildGithubAgentToolSelectionCatalog","DEFAULT_JOB_LOG_TAIL_LINES","GITHUB_GRAPHQL_ROUTE","GITHUB_ARTIFACT_ARCHIVE_FORMAT","GITHUB_ARTIFACT_DOWNLOAD_ROUTE","GITHUB_ARTIFACT_DOWNLOAD_TIMEOUT_MS","GITHUB_APP_BOT_SUFFIX","PENDING_REVIEW_PAGE_SIZE","PENDING_REVIEW_MAX_PAGE_REQUESTS","PENDING_REVIEW_LOOKUP_TIMEOUT_MS","PENDING_REVIEW_PAGE_TIMEOUT_MS","PENDING_REVIEW_PAGE_PATTERN","NO_PENDING_REVIEW_MESSAGE","ADD_PENDING_REVIEW_COMMENT_MUTATION","GithubAgentToolsProvider","options","tokenProvider","catalog","selectionCatalog","openSession","input","installation","getInstallationByConnectionId","connection","id","installationId","Number","isSafeInteger","tokenPromise","call","tool","tools","find","candidate","toolId","githubToolError","operation","resolveGithubOperation","undefined","validationError","validateGithubToolArguments","arguments","getInstallationAccessToken","token","hasGrantedPermissions","permissions","client","createClient","createOctokitClient","method","kind","data","addCommentToPendingReview","parameters","githubToolResult","operationParameters","resolvePendingReviewParameters","response","request","route","octokit","auth","baseUrl","retry","enabled","abortController","AbortController","timeout","setTimeout","abort","redirect","parseSuccessResponseBody","signal","clearTimeout","graphql","query","variables","args","params","methods","some","githubOperationRoute","projectGithubOperationParameters","owner","repo","issue","pull","run","resource","repoPath","comment_id","reaction","body","review","latestPendingReview","nodeId","pullRequestReviewId","path","subjectType","subject_type","line","side","start_line","startLine","start_side","startSide","content","headers","accept","isPendingReviewOperation","review_id","requiredIdentifier","lookupController","lookupTimeout","latestPendingReviewBeforeDeadline","lookupSignal","firstPage","requestPendingReviewPage","lastPage","pendingReviewLastPage","requests","malformed","page","Array","isArray","result","latestPendingReviewOnPage","pageController","abortPage","aborted","addEventListener","once","pageTimeout","pull_number","per_page","removeEventListener","link","lastLink","split","part","includes","match","exec","NaN","parseInt","appLogin","githubAppBotLogin","toLowerCase","index","length","isRecord","state","userLogin","user","login","trim","node_id","reference","configuredUsername","GITHUB_APP_USERNAME","GITHUB_APP_SLUG","endsWith","structuredContent","projectGithubToolOutput","type","text","JSON","stringify","projectGithubArtifactDownloadOutput","issue_types","issues","githubSearchItems","pull_requests","pull_request","merge","downloadUrl","location","output","archive_format","download_url","resource_id","artifact_id","contentType","content_type","contentLength","sizeBytes","size_bytes","items","message","code","isError","value","arguments_","required","inputSchema","name","methodRequired","methodRequiredParameters","properties","propertySchemas","Object","entries","schema","isInteger","oneOf","methodSchema","const","filter","granted","requiredScope","every","permission","access","actual"],"mappings":"AASA,SAAQA,OAAO,QAAO,UAAU;AAChC,SAAQC,cAAc,QAAO,iBAAiB;AAC9C,SACEC,qCAAqC,QAEhC,sCAAsC;AAC7C,SAAQC,MAAM,EAAEC,0BAA0B,QAAO,aAAa;AAE9D,SAAQC,8BAA8B,QAAO,cAAc;AAC3D,SAIEC,sBAAsB,EACtBC,+BAA+B,QAC1B,iCAAiC;AAYxC,SACEC,oCAAoC,EACpCC,0BAA0B,EAC1BH,sBAAsB,EACtBC,+BAA+B,QAC1B,iCAAiC;AAgBxC,MAAMG,uBAAuB;AAC7B,MAAMC,iCAAiC;AACvC,MAAMC,iCAAiC,CAAC,0DAA0D,EAAED,gCAAgC;AACpI,MAAME,sCAAsC;AAC5C,MAAMC,wBAAwB;AAC9B,MAAMC,2BAA2B;AACjC,MAAMC,mCAAmC;AACzC,MAAMC,mCAAmC;AACzC,MAAMC,iCAAiC;AACvC,MAAMC,8BAA8B;AACpC,MAAMC,4BACJ;AAEF,MAAMC,sCAAsC,CAAC;;;;;;;;AAQ7C,CAAC;AAED,OAAO,MAAMC;IAWX,YAAY,AAAiBC,UAA2C,CAAC,CAAC,CAAE;aAA/CA,UAAAA;QAC3B,IA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3F,UAAUgK,QAAQ,IACnChK,UAAUgK,QAAQ,CAACc,MAAM,CAAC,CAACZ,OAAyB,OAAOA,SAAS,YACpE,EAAE;IACR;IAEA,OAAO,EAAE;AACX;AAEA,SAASvJ,sBACPoK,OAAmD,EACnDlL,IAAyD,EACzDD,IAAwB;IAExB,MAAMoB,SAAS,OAAOpB,KAAKY,SAAS,CAACQ,MAAM,KAAK,WAAWpB,KAAKY,SAAS,CAACQ,MAAM,GAAGX;IACnF,MAAM2J,WACJnK,KAAKiD,OAAO,EAAE/C,KAAK,CAACC,YAAcA,UAAUT,EAAE,KAAKyB,SAASgK,iBAAiBnL,KAAKmL,aAAa;IACjG,OAAOhB,SAASiB,KAAK,CAAC,CAAC,EAACC,UAAU,EAAEC,MAAM,EAAC;QACzC,MAAMC,SAASL,OAAO,CAACG,WAAW;QAClC,OAAOE,WAAW,WAAWA,WAAW,WAAWA,WAAWD;IAChE;AACF"}
|
|
@@ -575,7 +575,7 @@ export const githubAgentToolCatalog = [
|
|
|
575
575
|
tool({
|
|
576
576
|
id: 'add_comment_to_pending_review',
|
|
577
577
|
category: 'pull_requests',
|
|
578
|
-
description: "Add review comment to the requester's latest pending pull request review.
|
|
578
|
+
description: "Add a review comment to the requester's latest pending pull request review. The comment remains part of that pending review until it is submitted; a pending review needs to already exist to call this.",
|
|
579
579
|
sensitivity: 'write',
|
|
580
580
|
sensitive: false,
|
|
581
581
|
requiredScope: scopes.pullRequestsWrite,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/github-agent-tool-catalog.ts"],"sourcesContent":["type AgentToolSensitivity = 'read' | 'write';\ntype AgentToolJsonSchema = Record<string, unknown>;\n\ninterface AgentToolCatalogMethod<RequiredScope = unknown> {\n id: string;\n description: string;\n sensitivity: AgentToolSensitivity;\n sensitive: boolean;\n requiredScope: RequiredScope;\n}\n\ninterface AgentToolCatalogEntry<RequiredScope = unknown> {\n id: string;\n description: string;\n sensitivity: AgentToolSensitivity;\n sensitive: boolean;\n requiredScope: RequiredScope;\n inputSchema: AgentToolJsonSchema;\n outputSchema?: AgentToolJsonSchema | undefined;\n methods?: readonly AgentToolCatalogMethod<RequiredScope>[] | undefined;\n}\n\ninterface AgentToolSelector {\n readonly token: string;\n readonly kind: 'family' | 'family_wildcard' | 'method' | 'standalone';\n readonly sensitivity: AgentToolSensitivity;\n readonly sensitive: boolean;\n}\n\ninterface AgentToolSelectionCatalog {\n readonly selectors: readonly AgentToolSelector[];\n}\n\nexport const DEFAULT_JOB_LOG_TAIL_LINES = 500;\n\nexport type GithubAgentToolCategory = 'issues' | 'pull_requests' | 'actions';\nexport type GithubAgentToolPermission = 'actions' | 'contents' | 'issues' | 'pull_requests';\nexport type GithubAgentToolPermissionAccess = 'read' | 'write';\nexport type GithubAgentToolSensitivity = 'read' | 'write';\n\nexport interface GithubAgentToolRequiredPermission {\n permission: GithubAgentToolPermission;\n access: GithubAgentToolPermissionAccess;\n}\n\nexport type GithubAgentToolRequiredScope = readonly GithubAgentToolRequiredPermission[];\n\nexport type GithubAgentToolCatalogMethod = AgentToolCatalogMethod<GithubAgentToolRequiredScope>;\n\nexport interface GithubAgentToolCatalogEntry\n extends AgentToolCatalogEntry<GithubAgentToolRequiredScope> {\n category: GithubAgentToolCategory;\n methods?: readonly GithubAgentToolCatalogMethod[] | undefined;\n}\n\ninterface GithubAgentToolCatalogInput {\n id: string;\n category: GithubAgentToolCategory;\n description: string;\n inputSchema: AgentToolJsonSchema;\n outputSchema: AgentToolJsonSchema;\n sensitivity?: GithubAgentToolSensitivity | undefined;\n sensitive?: boolean | undefined;\n requiredScope?: GithubAgentToolRequiredScope | undefined;\n methods?: readonly GithubAgentToolCatalogMethod[] | undefined;\n}\n\nconst scopes = {\n issuesRead: [{permission: 'issues', access: 'read'}],\n issuesWrite: [{permission: 'issues', access: 'write'}],\n pullRequestsRead: [{permission: 'pull_requests', access: 'read'}],\n pullRequestsWrite: [{permission: 'pull_requests', access: 'write'}],\n actionsRead: [{permission: 'actions', access: 'read'}],\n actionsWrite: [{permission: 'actions', access: 'write'}],\n mergePullRequest: [\n {permission: 'pull_requests', access: 'write'},\n {permission: 'contents', access: 'write'},\n ],\n} as const satisfies Record<string, GithubAgentToolRequiredScope>;\n\nconst repositoryProperties = {\n owner: stringSchema('Repository owner'),\n repo: stringSchema('Repository name'),\n};\n\nconst pageProperties = {\n page: integerSchema('Page number for pagination', {minimum: 1}),\n per_page: integerSchema('Results per page for pagination', {minimum: 1, maximum: 100}),\n};\n\nconst issueReadMethods = [\n method('get', 'Get information about a specific issue.', 'read', false, scopes.issuesRead),\n method('get_comments', 'Get comments on a specific issue.', 'read', false, scopes.issuesRead),\n method(\n 'get_sub_issues',\n 'Get sub-issues for a specific issue.',\n 'read',\n false,\n scopes.issuesRead,\n ),\n method(\n 'get_parent',\n 'Get the parent issue for a specific issue.',\n 'read',\n false,\n scopes.issuesRead,\n ),\n method(\n 'get_labels',\n 'Get labels assigned to a specific issue.',\n 'read',\n false,\n scopes.issuesRead,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst issueWriteMethods = [\n method('create', 'Create a new issue.', 'write', false, scopes.issuesWrite),\n method('update', 'Update an existing issue.', 'write', false, scopes.issuesWrite),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst subIssueWriteMethods = [\n method('add', 'Add a sub-issue to a parent issue.', 'write', false, scopes.issuesWrite),\n method('remove', 'Remove a sub-issue from a parent issue.', 'write', false, scopes.issuesWrite),\n method(\n 'reprioritize',\n 'Reprioritize a sub-issue under its parent issue.',\n 'write',\n false,\n scopes.issuesWrite,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst pullRequestReadMethods = [\n method(\n 'get',\n 'Get information about a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_diff',\n 'Get the diff for a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_status',\n 'Get status information for a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_files',\n 'Get files changed in a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_commits',\n 'Get commits in a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_review_comments',\n 'Get review comments for a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_reviews',\n 'Get reviews for a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_comments',\n 'Get conversation comments for a specific pull request.',\n 'read',\n false,\n scopes.issuesRead,\n ),\n method(\n 'get_check_runs',\n 'Get check runs for the head commit of a pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst pullRequestReviewWriteMethods = [\n method(\n 'create',\n 'Create a pending pull request review.',\n 'write',\n false,\n scopes.pullRequestsWrite,\n ),\n method(\n 'submit_pending',\n 'Submit the latest pending pull request review.',\n 'write',\n false,\n scopes.pullRequestsWrite,\n ),\n method(\n 'delete_pending',\n 'Delete the latest pending pull request review.',\n 'write',\n false,\n scopes.pullRequestsWrite,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst actionsListMethods = [\n method('list_workflows', 'List workflows in a repository.', 'read', false, scopes.actionsRead),\n method(\n 'list_workflow_runs',\n 'List workflow runs in a repository or for a workflow.',\n 'read',\n false,\n scopes.actionsRead,\n ),\n method('list_workflow_jobs', 'List jobs for a workflow run.', 'read', false, scopes.actionsRead),\n method(\n 'list_workflow_run_artifacts',\n 'List artifacts for a workflow run.',\n 'read',\n false,\n scopes.actionsRead,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst actionsGetMethods = [\n method('get_workflow', 'Get details for a workflow.', 'read', false, scopes.actionsRead),\n method('get_workflow_run', 'Get details for a workflow run.', 'read', false, scopes.actionsRead),\n method('get_workflow_job', 'Get details for a workflow job.', 'read', false, scopes.actionsRead),\n method(\n 'download_workflow_run_artifact',\n 'Download a workflow run artifact.',\n 'read',\n false,\n scopes.actionsRead,\n ),\n method('get_workflow_run_usage', 'Get workflow run usage.', 'read', false, scopes.actionsRead),\n method(\n 'get_workflow_run_logs_url',\n 'Get a workflow run logs download URL.',\n 'read',\n false,\n scopes.actionsRead,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst actionsRunTriggerMethods = [\n method('run_workflow', 'Trigger a workflow_dispatch run.', 'write', true, scopes.actionsWrite),\n method('rerun_workflow_run', 'Rerun a workflow run.', 'write', false, scopes.actionsWrite),\n method(\n 'rerun_failed_jobs',\n 'Rerun failed jobs in a workflow run.',\n 'write',\n false,\n scopes.actionsWrite,\n ),\n method('cancel_workflow_run', 'Cancel a workflow run.', 'write', false, scopes.actionsWrite),\n method(\n 'delete_workflow_run_logs',\n 'Delete logs for a workflow run.',\n 'write',\n true,\n scopes.actionsWrite,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nexport const githubAgentToolCatalog = [\n tool({\n id: 'issue_read',\n category: 'issues',\n description: 'Get information about a specific issue in a GitHub repository.',\n methods: issueReadMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(issueReadMethods, 'The read operation to perform on a single issue'),\n issue_number: integerSchema('The number of the issue'),\n ...pageProperties,\n },\n ['method', 'issue_number'],\n ),\n outputSchema: openObjectSchema('Issue read result'),\n }),\n tool({\n id: 'list_issue_types',\n category: 'issues',\n description:\n 'List supported issue types for a repository or its owner organization. When repo is omitted, returns org-level issue types directly.',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.issuesRead,\n inputSchema: objectSchema(\n {\n owner: stringSchema('The account owner of the repository or organization'),\n repo: stringSchema('The name of the repository'),\n },\n ['owner'],\n ),\n outputSchema: objectSchema({issue_types: arraySchema(openObjectSchema('Issue type'))}, [\n 'issue_types',\n ]),\n }),\n tool({\n id: 'list_issues',\n category: 'issues',\n description:\n \"List issues in a GitHub repository. For pagination, use the 'endCursor' from the previous response's 'pageInfo' in the 'after' parameter.\",\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.issuesRead,\n inputSchema: repositoryInputSchema({\n state: enumSchema(['OPEN', 'CLOSED'], 'Filter by state'),\n labels: arraySchema(stringSchema('Label name')),\n orderBy: enumSchema(['CREATED_AT', 'UPDATED_AT', 'COMMENTS'], 'Order issues by field'),\n direction: enumSchema(['ASC', 'DESC'], 'Order direction'),\n since: stringSchema('Filter by date (ISO 8601 timestamp)'),\n after: stringSchema('Pagination cursor'),\n first: integerSchema('Number of issues to return', {minimum: 1, maximum: 100}),\n }),\n outputSchema: objectSchema({issues: arraySchema(openObjectSchema('GitHub issue'))}, ['issues']),\n }),\n tool({\n id: 'search_issues',\n category: 'issues',\n description:\n 'Search for issues in GitHub repositories using issues search syntax already scoped to is:issue',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.issuesRead,\n inputSchema: objectSchema(\n {\n query: stringSchema('Search query using GitHub issues search syntax'),\n owner: stringSchema('Optional repository owner'),\n repo: stringSchema('Optional repository name'),\n sort: enumSchema(\n [\n 'comments',\n 'reactions',\n 'reactions-+1',\n 'reactions--1',\n 'reactions-smile',\n 'reactions-thinking_face',\n 'reactions-heart',\n 'reactions-tada',\n 'interactions',\n 'created',\n 'updated',\n ],\n 'Sort field',\n ),\n order: enumSchema(['asc', 'desc'], 'Sort order'),\n ...pageProperties,\n },\n ['query'],\n ),\n outputSchema: objectSchema({issues: arraySchema(openObjectSchema('GitHub issue'))}, ['issues']),\n }),\n tool({\n id: 'add_issue_comment',\n category: 'issues',\n description:\n 'Add a comment and/or reaction to a specific issue or issue comment in a GitHub repository. Use this tool with pull requests as well, but only if the user is not asking specifically to add or react to review comments. At least one of body or reaction is required.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.issuesWrite,\n inputSchema: repositoryInputSchema(\n {\n issue_number: integerSchema('Issue or pull request number to comment on or react to'),\n comment_id: integerSchema(\n 'The numeric ID of the issue or pull request comment to react to',\n ),\n body: stringSchema('Comment content. Required unless reaction is provided'),\n reaction: enumSchema(\n ['+1', '-1', 'laugh', 'confused', 'heart', 'hooray', 'rocket', 'eyes'],\n 'Emoji reaction to add. Required unless body is provided',\n ),\n },\n [],\n {\n anyOf: [\n {required: ['issue_number', 'body']},\n {required: ['issue_number', 'reaction']},\n {required: ['comment_id', 'reaction']},\n ],\n },\n ),\n outputSchema: openObjectSchema('Created issue comment or reaction'),\n }),\n tool({\n id: 'issue_write',\n category: 'issues',\n description: 'Create a new or update an existing issue in a GitHub repository.',\n methods: issueWriteMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(issueWriteMethods, 'Write operation to perform on a single issue'),\n issue_number: integerSchema('Issue number to update'),\n title: stringSchema('Issue title'),\n body: stringSchema('Issue body content'),\n assignees: arraySchema(stringSchema('GitHub username')),\n labels: arraySchema(stringSchema('Label name')),\n milestone: integerSchema('Milestone number'),\n issue_type: stringSchema('Type of this issue'),\n state: enumSchema(['open', 'closed'], 'New state'),\n state_reason: enumSchema(\n ['completed', 'not_planned', 'duplicate'],\n 'Reason for the state change',\n ),\n duplicate_of: integerSchema('Issue number that this issue is a duplicate of'),\n },\n ['method'],\n ),\n outputSchema: openObjectSchema('Issue write result'),\n }),\n tool({\n id: 'sub_issue_write',\n category: 'issues',\n description:\n 'Add, remove, or reprioritize a sub-issue under a parent issue in a GitHub repository.',\n methods: subIssueWriteMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(subIssueWriteMethods, 'The action to perform on a single sub-issue'),\n issue_number: integerSchema('The number of the parent issue'),\n sub_issue_id: integerSchema('The ID of the sub-issue'),\n replace_parent: booleanSchema(\"Replace the sub-issue's current parent issue\"),\n after_id: integerSchema('The ID of the sub-issue to be prioritized after'),\n before_id: integerSchema('The ID of the sub-issue to be prioritized before'),\n },\n ['method', 'issue_number', 'sub_issue_id'],\n ),\n outputSchema: openObjectSchema('Sub-issue write result'),\n }),\n tool({\n id: 'pull_request_read',\n category: 'pull_requests',\n description: 'Get information on a specific pull request in a GitHub repository.',\n methods: pullRequestReadMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(\n pullRequestReadMethods,\n 'Action to specify what pull request data needs to be retrieved from GitHub',\n ),\n pull_number: integerSchema('Pull request number'),\n ref: stringSchema('Git reference to inspect. Required for get_status and get_check_runs'),\n cursor: stringSchema('Cursor for review comment pagination'),\n ...pageProperties,\n },\n ['method', 'pull_number'],\n {\n oneOf: [\n methodRequiredSchema('get', []),\n methodRequiredSchema('get_diff', []),\n methodRequiredSchema('get_status', ['ref']),\n methodRequiredSchema('get_files', []),\n methodRequiredSchema('get_commits', []),\n methodRequiredSchema('get_review_comments', []),\n methodRequiredSchema('get_reviews', []),\n methodRequiredSchema('get_comments', []),\n methodRequiredSchema('get_check_runs', ['ref']),\n ],\n },\n ),\n outputSchema: openObjectSchema('Pull request read result'),\n }),\n tool({\n id: 'list_pull_requests',\n category: 'pull_requests',\n description:\n 'List pull requests in a GitHub repository. If the user specifies an author, then do not use this tool and use the search_pull_requests tool instead.',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.pullRequestsRead,\n inputSchema: repositoryInputSchema({\n state: enumSchema(['open', 'closed', 'all'], 'Filter by state'),\n head: stringSchema('Filter by head user/org and branch'),\n base: stringSchema('Filter by base branch'),\n sort: enumSchema(['created', 'updated', 'popularity', 'long-running'], 'Sort by'),\n direction: enumSchema(['asc', 'desc'], 'Sort direction'),\n ...pageProperties,\n }),\n outputSchema: objectSchema(\n {pull_requests: arraySchema(openObjectSchema('GitHub pull request'))},\n ['pull_requests'],\n ),\n }),\n tool({\n id: 'search_pull_requests',\n category: 'pull_requests',\n description:\n 'Search for pull requests in GitHub repositories using issues search syntax already scoped to is:pr',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.pullRequestsRead,\n inputSchema: objectSchema(\n {\n query: stringSchema('Search query using GitHub pull request search syntax'),\n owner: stringSchema('Optional repository owner'),\n repo: stringSchema('Optional repository name'),\n sort: enumSchema(\n [\n 'comments',\n 'reactions',\n 'reactions-+1',\n 'reactions--1',\n 'reactions-smile',\n 'reactions-thinking_face',\n 'reactions-heart',\n 'reactions-tada',\n 'interactions',\n 'created',\n 'updated',\n ],\n 'Sort field',\n ),\n order: enumSchema(['asc', 'desc'], 'Sort order'),\n ...pageProperties,\n },\n ['query'],\n ),\n outputSchema: objectSchema(\n {pull_requests: arraySchema(openObjectSchema('GitHub pull request'))},\n ['pull_requests'],\n ),\n }),\n tool({\n id: 'create_pull_request',\n category: 'pull_requests',\n description: 'Create a new pull request in a GitHub repository.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n title: stringSchema('PR title'),\n body: stringSchema('PR description'),\n head: stringSchema('Branch containing changes'),\n base: stringSchema('Branch to merge into'),\n draft: booleanSchema('Create as draft PR'),\n maintainer_can_modify: booleanSchema('Allow maintainer edits'),\n reviewers: arraySchema(stringSchema('GitHub username or ORG/team-slug reviewer')),\n },\n ['title', 'head', 'base'],\n ),\n outputSchema: objectSchema({pull_request: openObjectSchema('Created GitHub pull request')}, [\n 'pull_request',\n ]),\n }),\n tool({\n id: 'update_pull_request',\n category: 'pull_requests',\n description: 'Update an existing pull request in a GitHub repository.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number to update'),\n title: stringSchema('New title'),\n body: stringSchema('New description'),\n state: enumSchema(['open', 'closed'], 'New state'),\n base: stringSchema('New base branch name'),\n maintainer_can_modify: booleanSchema('Allow maintainer edits'),\n reviewers: arraySchema(stringSchema('GitHub username or ORG/team-slug reviewer')),\n },\n ['pull_number'],\n ),\n outputSchema: objectSchema({pull_request: openObjectSchema('Updated GitHub pull request')}, [\n 'pull_request',\n ]),\n }),\n tool({\n id: 'add_reply_to_pull_request_comment',\n category: 'pull_requests',\n description:\n 'Add a reply and/or reaction to an existing pull request comment. This can create a new comment linked as a reply to the specified comment, add an emoji reaction to the specified comment, or do both. At least one of body or reaction is required.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number. Required when body is provided'),\n comment_id: integerSchema(\n 'The numeric ID of the pull request review comment to reply or react to',\n ),\n body: stringSchema('The text of the reply'),\n reaction: enumSchema(\n ['+1', '-1', 'laugh', 'confused', 'heart', 'hooray', 'rocket', 'eyes'],\n 'Emoji reaction to add',\n ),\n },\n ['comment_id'],\n {anyOf: [{required: ['pull_number', 'body']}, {required: ['reaction']}]},\n ),\n outputSchema: openObjectSchema('Pull request comment reply or reaction result'),\n }),\n tool({\n id: 'merge_pull_request',\n category: 'pull_requests',\n description: 'Merge a pull request in a GitHub repository.',\n sensitivity: 'write',\n sensitive: true,\n requiredScope: scopes.mergePullRequest,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number'),\n commit_title: stringSchema('Title for merge commit'),\n commit_message: stringSchema('Extra detail for merge commit'),\n merge_method: enumSchema(['merge', 'squash', 'rebase'], 'Merge method'),\n },\n ['pull_number'],\n ),\n outputSchema: objectSchema({merge: openObjectSchema('Merge result')}, ['merge']),\n }),\n tool({\n id: 'update_pull_request_branch',\n category: 'pull_requests',\n description:\n 'Update the branch of a pull request with the latest changes from the base branch.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number'),\n expected_head_sha: stringSchema(\"The expected SHA of the pull request's HEAD ref\"),\n },\n ['pull_number'],\n ),\n outputSchema: openObjectSchema('Pull request branch update result'),\n }),\n tool({\n id: 'pull_request_review_write',\n category: 'pull_requests',\n description: 'Create and/or submit, delete review of a pull request.',\n methods: pullRequestReviewWriteMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(\n pullRequestReviewWriteMethods,\n 'The write operation to perform on pull request review',\n ),\n pull_number: integerSchema('Pull request number'),\n body: stringSchema('Review comment text'),\n event: enumSchema(['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], 'Review action to perform'),\n commit_id: stringSchema('SHA of commit to review'),\n },\n ['method', 'pull_number'],\n ),\n outputSchema: openObjectSchema('Pull request review write result'),\n }),\n tool({\n id: 'add_comment_to_pending_review',\n category: 'pull_requests',\n description:\n \"Add review comment to the requester's latest pending pull request review. A pending review needs to already exist to call this.\",\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number'),\n path: stringSchema('The relative path to the file that necessitates a comment'),\n body: stringSchema('The text of the review comment'),\n subject_type: enumSchema(['LINE', 'FILE'], 'The level at which the comment is targeted'),\n line: integerSchema('The line of the blob in the pull request diff'),\n side: enumSchema(['LEFT', 'RIGHT'], 'The side of the diff to comment on'),\n start_line: integerSchema('The first line of a multi-line comment range'),\n start_side: enumSchema(\n ['LEFT', 'RIGHT'],\n 'The starting side of a multi-line comment range',\n ),\n },\n ['pull_number', 'path', 'body'],\n ),\n outputSchema: openObjectSchema('Pending review comment result'),\n }),\n tool({\n id: 'actions_list',\n category: 'actions',\n description:\n 'Tools for listing GitHub Actions resources. Use this tool to list workflows in a repository, or list workflow runs, jobs, and artifacts for a specific workflow or workflow run.',\n methods: actionsListMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(actionsListMethods, 'The action to perform'),\n resource_id: stringSchema('The unique identifier of the resource'),\n workflow_runs_filter: openObjectSchema('Filters for workflow runs'),\n workflow_jobs_filter: openObjectSchema('Filters for workflow jobs'),\n ...pageProperties,\n },\n ['method'],\n ),\n outputSchema: openObjectSchema('Actions list result'),\n }),\n tool({\n id: 'actions_get',\n category: 'actions',\n description:\n 'Get details about specific GitHub Actions resources. Use this tool to get details about individual workflows, workflow runs, jobs, and artifacts by their unique IDs.',\n methods: actionsGetMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(actionsGetMethods, 'The method to execute'),\n resource_id: stringSchema('The unique identifier of the resource'),\n },\n ['method', 'resource_id'],\n ),\n outputSchema: openObjectSchema('Actions get result'),\n }),\n tool({\n id: 'actions_run_trigger',\n category: 'actions',\n description:\n 'Trigger GitHub Actions workflow operations, including running, re-running, cancelling workflow runs, and deleting workflow run logs.',\n methods: actionsRunTriggerMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(actionsRunTriggerMethods, 'The method to execute'),\n workflow_id: stringSchema(\n 'The workflow ID or workflow file name. Required for run_workflow',\n ),\n ref: stringSchema('The git reference for the workflow. Required for run_workflow'),\n inputs: openObjectSchema('Inputs the workflow accepts. Only used for run_workflow'),\n run_id: integerSchema(\n 'The ID of the workflow run. Required for all methods except run_workflow',\n ),\n },\n ['method'],\n {\n oneOf: [\n methodRequiredSchema('run_workflow', ['workflow_id', 'ref']),\n methodRequiredSchema('rerun_workflow_run', ['run_id']),\n methodRequiredSchema('rerun_failed_jobs', ['run_id']),\n methodRequiredSchema('cancel_workflow_run', ['run_id']),\n methodRequiredSchema('delete_workflow_run_logs', ['run_id']),\n ],\n },\n ),\n outputSchema: openObjectSchema('Actions run trigger result'),\n }),\n tool({\n id: 'get_job_logs',\n category: 'actions',\n description:\n 'Get logs for GitHub Actions workflow jobs. Use this tool to retrieve logs for a specific job or all failed jobs in a workflow run. For single job logs, provide job_id. For all failed jobs in a run, provide run_id with failed_only=true.',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.actionsRead,\n inputSchema: repositoryInputSchema({\n job_id: numberSchema(\n 'The unique identifier of the workflow job. Required when getting logs for a single job.',\n ),\n run_id: numberSchema(\n 'The unique identifier of the workflow run. Required when failed_only is true to get logs for all failed jobs in the run.',\n ),\n failed_only: booleanSchema(\n 'When true, gets logs for all failed jobs in the workflow run specified by run_id. Requires run_id to be provided.',\n ),\n return_content: booleanSchema('Returns actual log content instead of URLs'),\n tail_lines: {\n ...numberSchema('Number of lines to return from the end of the log'),\n default: DEFAULT_JOB_LOG_TAIL_LINES,\n },\n }),\n outputSchema: openObjectSchema('GitHub Actions workflow job logs'),\n }),\n] as const satisfies readonly GithubAgentToolCatalogEntry[];\n\nexport type GithubAgentToolId = (typeof githubAgentToolCatalog)[number]['id'];\n\nexport function buildGithubAgentToolSelectionCatalog(\n catalog: readonly GithubAgentToolCatalogEntry[],\n): AgentToolSelectionCatalog {\n return {\n selectors: catalog.flatMap((entry): AgentToolSelector[] => {\n if (!entry.methods) {\n return [\n {\n token: entry.id,\n kind: 'standalone',\n sensitivity: entry.sensitivity,\n sensitive: entry.sensitive,\n },\n ];\n }\n\n return [\n {\n token: entry.id,\n kind: 'family',\n sensitivity: entry.sensitivity,\n sensitive: entry.sensitive,\n },\n {\n token: `${entry.id}.*`,\n kind: 'family_wildcard',\n sensitivity: entry.sensitivity,\n sensitive: entry.sensitive,\n },\n ...entry.methods.map((method) => ({\n token: `${entry.id}.${method.id}`,\n kind: 'method' as const,\n sensitivity: method.sensitivity,\n sensitive: method.sensitive,\n })),\n ];\n }),\n };\n}\n\nexport const githubAgentToolSelectionCatalog =\n buildGithubAgentToolSelectionCatalog(githubAgentToolCatalog);\n\nfunction tool(input: GithubAgentToolCatalogInput): GithubAgentToolCatalogEntry {\n if (!input.methods) {\n if (!input.sensitivity || input.sensitive === undefined || !input.requiredScope) {\n throw new Error(`GitHub agent tool ${input.id} is missing sensitivity or required scope`);\n }\n return {\n id: input.id,\n category: input.category,\n description: input.description,\n sensitivity: input.sensitivity,\n sensitive: input.sensitive,\n requiredScope: input.requiredScope,\n inputSchema: input.inputSchema,\n outputSchema: input.outputSchema,\n };\n }\n\n return {\n id: input.id,\n category: input.category,\n description: input.description,\n sensitivity: input.methods.some((candidate) => candidate.sensitivity === 'write')\n ? 'write'\n : 'read',\n sensitive: input.methods.some((candidate) => candidate.sensitive),\n requiredScope: unionRequiredScopes(input.methods),\n inputSchema: input.inputSchema,\n outputSchema: input.outputSchema,\n methods: input.methods,\n };\n}\n\nfunction method(\n id: string,\n description: string,\n sensitivity: GithubAgentToolSensitivity,\n sensitive: boolean,\n requiredScope: GithubAgentToolRequiredScope,\n): GithubAgentToolCatalogMethod {\n return {id, description, sensitivity, sensitive, requiredScope};\n}\n\nfunction unionRequiredScopes(\n methods: readonly GithubAgentToolCatalogMethod[],\n): GithubAgentToolRequiredScope {\n const byPermission = new Map<GithubAgentToolPermission, GithubAgentToolPermissionAccess>();\n\n for (const {requiredScope} of methods) {\n for (const {permission, access} of requiredScope) {\n if (byPermission.get(permission) === 'write') continue;\n byPermission.set(permission, access);\n }\n }\n\n return [...byPermission.entries()].map(([permission, access]) => ({permission, access}));\n}\n\nfunction repositoryInputSchema(\n properties: Record<string, AgentToolJsonSchema> = {},\n required: string[] = [],\n extraSchema: Partial<AgentToolJsonSchema> = {},\n): AgentToolJsonSchema {\n return objectSchema(\n {...repositoryProperties, ...properties},\n ['owner', 'repo', ...required],\n extraSchema,\n );\n}\n\nfunction objectSchema(\n properties: Record<string, AgentToolJsonSchema>,\n required: string[] = [],\n extraSchema: Partial<AgentToolJsonSchema> = {},\n): AgentToolJsonSchema {\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n ...(required.length > 0 ? {required} : {}),\n ...extraSchema,\n };\n}\n\nfunction methodRequiredSchema(methodId: string, required: string[]): AgentToolJsonSchema {\n return {\n properties: {\n method: {const: methodId},\n },\n required,\n };\n}\n\nfunction openObjectSchema(description: string): AgentToolJsonSchema {\n return {type: 'object', description, additionalProperties: true};\n}\n\nfunction stringSchema(description?: string): AgentToolJsonSchema {\n return {type: 'string', ...(description ? {description} : {})};\n}\n\nfunction integerSchema(\n description?: string,\n options: {minimum?: number | undefined; maximum?: number | undefined} = {},\n): AgentToolJsonSchema {\n return {type: 'integer', ...(description ? {description} : {}), ...options};\n}\n\nfunction numberSchema(description?: string): AgentToolJsonSchema {\n return {type: 'number', ...(description ? {description} : {})};\n}\n\nfunction booleanSchema(description: string): AgentToolJsonSchema {\n return {type: 'boolean', description};\n}\n\nfunction enumSchema(values: string[], description: string): AgentToolJsonSchema {\n return {type: 'string', description, enum: values};\n}\n\nfunction methodSchema(\n methods: readonly GithubAgentToolCatalogMethod[],\n description: string,\n): AgentToolJsonSchema {\n return enumSchema(\n methods.map((candidate) => candidate.id),\n description,\n );\n}\n\nfunction arraySchema(items: AgentToolJsonSchema): AgentToolJsonSchema {\n return {type: 'array', items};\n}\n"],"names":["DEFAULT_JOB_LOG_TAIL_LINES","scopes","issuesRead","permission","access","issuesWrite","pullRequestsRead","pullRequestsWrite","actionsRead","actionsWrite","mergePullRequest","repositoryProperties","owner","stringSchema","repo","pageProperties","page","integerSchema","minimum","per_page","maximum","issueReadMethods","method","issueWriteMethods","subIssueWriteMethods","pullRequestReadMethods","pullRequestReviewWriteMethods","actionsListMethods","actionsGetMethods","actionsRunTriggerMethods","githubAgentToolCatalog","tool","id","category","description","methods","inputSchema","repositoryInputSchema","methodSchema","issue_number","outputSchema","openObjectSchema","sensitivity","sensitive","requiredScope","objectSchema","issue_types","arraySchema","state","enumSchema","labels","orderBy","direction","since","after","first","issues","query","sort","order","comment_id","body","reaction","anyOf","required","title","assignees","milestone","issue_type","state_reason","duplicate_of","sub_issue_id","replace_parent","booleanSchema","after_id","before_id","pull_number","ref","cursor","oneOf","methodRequiredSchema","head","base","pull_requests","draft","maintainer_can_modify","reviewers","pull_request","commit_title","commit_message","merge_method","merge","expected_head_sha","event","commit_id","path","subject_type","line","side","start_line","start_side","resource_id","workflow_runs_filter","workflow_jobs_filter","workflow_id","inputs","run_id","job_id","numberSchema","failed_only","return_content","tail_lines","default","buildGithubAgentToolSelectionCatalog","catalog","selectors","flatMap","entry","token","kind","map","githubAgentToolSelectionCatalog","input","undefined","Error","some","candidate","unionRequiredScopes","byPermission","Map","get","set","entries","properties","extraSchema","type","additionalProperties","length","methodId","const","options","values","enum","items"],"mappings":"AAiCA,OAAO,MAAMA,6B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
|
+
{"version":3,"sources":["../../src/core/github-agent-tool-catalog.ts"],"sourcesContent":["type AgentToolSensitivity = 'read' | 'write';\ntype AgentToolJsonSchema = Record<string, unknown>;\n\ninterface AgentToolCatalogMethod<RequiredScope = unknown> {\n id: string;\n description: string;\n sensitivity: AgentToolSensitivity;\n sensitive: boolean;\n requiredScope: RequiredScope;\n}\n\ninterface AgentToolCatalogEntry<RequiredScope = unknown> {\n id: string;\n description: string;\n sensitivity: AgentToolSensitivity;\n sensitive: boolean;\n requiredScope: RequiredScope;\n inputSchema: AgentToolJsonSchema;\n outputSchema?: AgentToolJsonSchema | undefined;\n methods?: readonly AgentToolCatalogMethod<RequiredScope>[] | undefined;\n}\n\ninterface AgentToolSelector {\n readonly token: string;\n readonly kind: 'family' | 'family_wildcard' | 'method' | 'standalone';\n readonly sensitivity: AgentToolSensitivity;\n readonly sensitive: boolean;\n}\n\ninterface AgentToolSelectionCatalog {\n readonly selectors: readonly AgentToolSelector[];\n}\n\nexport const DEFAULT_JOB_LOG_TAIL_LINES = 500;\n\nexport type GithubAgentToolCategory = 'issues' | 'pull_requests' | 'actions';\nexport type GithubAgentToolPermission = 'actions' | 'contents' | 'issues' | 'pull_requests';\nexport type GithubAgentToolPermissionAccess = 'read' | 'write';\nexport type GithubAgentToolSensitivity = 'read' | 'write';\n\nexport interface GithubAgentToolRequiredPermission {\n permission: GithubAgentToolPermission;\n access: GithubAgentToolPermissionAccess;\n}\n\nexport type GithubAgentToolRequiredScope = readonly GithubAgentToolRequiredPermission[];\n\nexport type GithubAgentToolCatalogMethod = AgentToolCatalogMethod<GithubAgentToolRequiredScope>;\n\nexport interface GithubAgentToolCatalogEntry\n extends AgentToolCatalogEntry<GithubAgentToolRequiredScope> {\n category: GithubAgentToolCategory;\n methods?: readonly GithubAgentToolCatalogMethod[] | undefined;\n}\n\ninterface GithubAgentToolCatalogInput {\n id: string;\n category: GithubAgentToolCategory;\n description: string;\n inputSchema: AgentToolJsonSchema;\n outputSchema: AgentToolJsonSchema;\n sensitivity?: GithubAgentToolSensitivity | undefined;\n sensitive?: boolean | undefined;\n requiredScope?: GithubAgentToolRequiredScope | undefined;\n methods?: readonly GithubAgentToolCatalogMethod[] | undefined;\n}\n\nconst scopes = {\n issuesRead: [{permission: 'issues', access: 'read'}],\n issuesWrite: [{permission: 'issues', access: 'write'}],\n pullRequestsRead: [{permission: 'pull_requests', access: 'read'}],\n pullRequestsWrite: [{permission: 'pull_requests', access: 'write'}],\n actionsRead: [{permission: 'actions', access: 'read'}],\n actionsWrite: [{permission: 'actions', access: 'write'}],\n mergePullRequest: [\n {permission: 'pull_requests', access: 'write'},\n {permission: 'contents', access: 'write'},\n ],\n} as const satisfies Record<string, GithubAgentToolRequiredScope>;\n\nconst repositoryProperties = {\n owner: stringSchema('Repository owner'),\n repo: stringSchema('Repository name'),\n};\n\nconst pageProperties = {\n page: integerSchema('Page number for pagination', {minimum: 1}),\n per_page: integerSchema('Results per page for pagination', {minimum: 1, maximum: 100}),\n};\n\nconst issueReadMethods = [\n method('get', 'Get information about a specific issue.', 'read', false, scopes.issuesRead),\n method('get_comments', 'Get comments on a specific issue.', 'read', false, scopes.issuesRead),\n method(\n 'get_sub_issues',\n 'Get sub-issues for a specific issue.',\n 'read',\n false,\n scopes.issuesRead,\n ),\n method(\n 'get_parent',\n 'Get the parent issue for a specific issue.',\n 'read',\n false,\n scopes.issuesRead,\n ),\n method(\n 'get_labels',\n 'Get labels assigned to a specific issue.',\n 'read',\n false,\n scopes.issuesRead,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst issueWriteMethods = [\n method('create', 'Create a new issue.', 'write', false, scopes.issuesWrite),\n method('update', 'Update an existing issue.', 'write', false, scopes.issuesWrite),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst subIssueWriteMethods = [\n method('add', 'Add a sub-issue to a parent issue.', 'write', false, scopes.issuesWrite),\n method('remove', 'Remove a sub-issue from a parent issue.', 'write', false, scopes.issuesWrite),\n method(\n 'reprioritize',\n 'Reprioritize a sub-issue under its parent issue.',\n 'write',\n false,\n scopes.issuesWrite,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst pullRequestReadMethods = [\n method(\n 'get',\n 'Get information about a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_diff',\n 'Get the diff for a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_status',\n 'Get status information for a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_files',\n 'Get files changed in a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_commits',\n 'Get commits in a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_review_comments',\n 'Get review comments for a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_reviews',\n 'Get reviews for a specific pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n method(\n 'get_comments',\n 'Get conversation comments for a specific pull request.',\n 'read',\n false,\n scopes.issuesRead,\n ),\n method(\n 'get_check_runs',\n 'Get check runs for the head commit of a pull request.',\n 'read',\n false,\n scopes.pullRequestsRead,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst pullRequestReviewWriteMethods = [\n method(\n 'create',\n 'Create a pending pull request review.',\n 'write',\n false,\n scopes.pullRequestsWrite,\n ),\n method(\n 'submit_pending',\n 'Submit the latest pending pull request review.',\n 'write',\n false,\n scopes.pullRequestsWrite,\n ),\n method(\n 'delete_pending',\n 'Delete the latest pending pull request review.',\n 'write',\n false,\n scopes.pullRequestsWrite,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst actionsListMethods = [\n method('list_workflows', 'List workflows in a repository.', 'read', false, scopes.actionsRead),\n method(\n 'list_workflow_runs',\n 'List workflow runs in a repository or for a workflow.',\n 'read',\n false,\n scopes.actionsRead,\n ),\n method('list_workflow_jobs', 'List jobs for a workflow run.', 'read', false, scopes.actionsRead),\n method(\n 'list_workflow_run_artifacts',\n 'List artifacts for a workflow run.',\n 'read',\n false,\n scopes.actionsRead,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst actionsGetMethods = [\n method('get_workflow', 'Get details for a workflow.', 'read', false, scopes.actionsRead),\n method('get_workflow_run', 'Get details for a workflow run.', 'read', false, scopes.actionsRead),\n method('get_workflow_job', 'Get details for a workflow job.', 'read', false, scopes.actionsRead),\n method(\n 'download_workflow_run_artifact',\n 'Download a workflow run artifact.',\n 'read',\n false,\n scopes.actionsRead,\n ),\n method('get_workflow_run_usage', 'Get workflow run usage.', 'read', false, scopes.actionsRead),\n method(\n 'get_workflow_run_logs_url',\n 'Get a workflow run logs download URL.',\n 'read',\n false,\n scopes.actionsRead,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nconst actionsRunTriggerMethods = [\n method('run_workflow', 'Trigger a workflow_dispatch run.', 'write', true, scopes.actionsWrite),\n method('rerun_workflow_run', 'Rerun a workflow run.', 'write', false, scopes.actionsWrite),\n method(\n 'rerun_failed_jobs',\n 'Rerun failed jobs in a workflow run.',\n 'write',\n false,\n scopes.actionsWrite,\n ),\n method('cancel_workflow_run', 'Cancel a workflow run.', 'write', false, scopes.actionsWrite),\n method(\n 'delete_workflow_run_logs',\n 'Delete logs for a workflow run.',\n 'write',\n true,\n scopes.actionsWrite,\n ),\n] as const satisfies readonly GithubAgentToolCatalogMethod[];\n\nexport const githubAgentToolCatalog = [\n tool({\n id: 'issue_read',\n category: 'issues',\n description: 'Get information about a specific issue in a GitHub repository.',\n methods: issueReadMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(issueReadMethods, 'The read operation to perform on a single issue'),\n issue_number: integerSchema('The number of the issue'),\n ...pageProperties,\n },\n ['method', 'issue_number'],\n ),\n outputSchema: openObjectSchema('Issue read result'),\n }),\n tool({\n id: 'list_issue_types',\n category: 'issues',\n description:\n 'List supported issue types for a repository or its owner organization. When repo is omitted, returns org-level issue types directly.',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.issuesRead,\n inputSchema: objectSchema(\n {\n owner: stringSchema('The account owner of the repository or organization'),\n repo: stringSchema('The name of the repository'),\n },\n ['owner'],\n ),\n outputSchema: objectSchema({issue_types: arraySchema(openObjectSchema('Issue type'))}, [\n 'issue_types',\n ]),\n }),\n tool({\n id: 'list_issues',\n category: 'issues',\n description:\n \"List issues in a GitHub repository. For pagination, use the 'endCursor' from the previous response's 'pageInfo' in the 'after' parameter.\",\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.issuesRead,\n inputSchema: repositoryInputSchema({\n state: enumSchema(['OPEN', 'CLOSED'], 'Filter by state'),\n labels: arraySchema(stringSchema('Label name')),\n orderBy: enumSchema(['CREATED_AT', 'UPDATED_AT', 'COMMENTS'], 'Order issues by field'),\n direction: enumSchema(['ASC', 'DESC'], 'Order direction'),\n since: stringSchema('Filter by date (ISO 8601 timestamp)'),\n after: stringSchema('Pagination cursor'),\n first: integerSchema('Number of issues to return', {minimum: 1, maximum: 100}),\n }),\n outputSchema: objectSchema({issues: arraySchema(openObjectSchema('GitHub issue'))}, ['issues']),\n }),\n tool({\n id: 'search_issues',\n category: 'issues',\n description:\n 'Search for issues in GitHub repositories using issues search syntax already scoped to is:issue',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.issuesRead,\n inputSchema: objectSchema(\n {\n query: stringSchema('Search query using GitHub issues search syntax'),\n owner: stringSchema('Optional repository owner'),\n repo: stringSchema('Optional repository name'),\n sort: enumSchema(\n [\n 'comments',\n 'reactions',\n 'reactions-+1',\n 'reactions--1',\n 'reactions-smile',\n 'reactions-thinking_face',\n 'reactions-heart',\n 'reactions-tada',\n 'interactions',\n 'created',\n 'updated',\n ],\n 'Sort field',\n ),\n order: enumSchema(['asc', 'desc'], 'Sort order'),\n ...pageProperties,\n },\n ['query'],\n ),\n outputSchema: objectSchema({issues: arraySchema(openObjectSchema('GitHub issue'))}, ['issues']),\n }),\n tool({\n id: 'add_issue_comment',\n category: 'issues',\n description:\n 'Add a comment and/or reaction to a specific issue or issue comment in a GitHub repository. Use this tool with pull requests as well, but only if the user is not asking specifically to add or react to review comments. At least one of body or reaction is required.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.issuesWrite,\n inputSchema: repositoryInputSchema(\n {\n issue_number: integerSchema('Issue or pull request number to comment on or react to'),\n comment_id: integerSchema(\n 'The numeric ID of the issue or pull request comment to react to',\n ),\n body: stringSchema('Comment content. Required unless reaction is provided'),\n reaction: enumSchema(\n ['+1', '-1', 'laugh', 'confused', 'heart', 'hooray', 'rocket', 'eyes'],\n 'Emoji reaction to add. Required unless body is provided',\n ),\n },\n [],\n {\n anyOf: [\n {required: ['issue_number', 'body']},\n {required: ['issue_number', 'reaction']},\n {required: ['comment_id', 'reaction']},\n ],\n },\n ),\n outputSchema: openObjectSchema('Created issue comment or reaction'),\n }),\n tool({\n id: 'issue_write',\n category: 'issues',\n description: 'Create a new or update an existing issue in a GitHub repository.',\n methods: issueWriteMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(issueWriteMethods, 'Write operation to perform on a single issue'),\n issue_number: integerSchema('Issue number to update'),\n title: stringSchema('Issue title'),\n body: stringSchema('Issue body content'),\n assignees: arraySchema(stringSchema('GitHub username')),\n labels: arraySchema(stringSchema('Label name')),\n milestone: integerSchema('Milestone number'),\n issue_type: stringSchema('Type of this issue'),\n state: enumSchema(['open', 'closed'], 'New state'),\n state_reason: enumSchema(\n ['completed', 'not_planned', 'duplicate'],\n 'Reason for the state change',\n ),\n duplicate_of: integerSchema('Issue number that this issue is a duplicate of'),\n },\n ['method'],\n ),\n outputSchema: openObjectSchema('Issue write result'),\n }),\n tool({\n id: 'sub_issue_write',\n category: 'issues',\n description:\n 'Add, remove, or reprioritize a sub-issue under a parent issue in a GitHub repository.',\n methods: subIssueWriteMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(subIssueWriteMethods, 'The action to perform on a single sub-issue'),\n issue_number: integerSchema('The number of the parent issue'),\n sub_issue_id: integerSchema('The ID of the sub-issue'),\n replace_parent: booleanSchema(\"Replace the sub-issue's current parent issue\"),\n after_id: integerSchema('The ID of the sub-issue to be prioritized after'),\n before_id: integerSchema('The ID of the sub-issue to be prioritized before'),\n },\n ['method', 'issue_number', 'sub_issue_id'],\n ),\n outputSchema: openObjectSchema('Sub-issue write result'),\n }),\n tool({\n id: 'pull_request_read',\n category: 'pull_requests',\n description: 'Get information on a specific pull request in a GitHub repository.',\n methods: pullRequestReadMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(\n pullRequestReadMethods,\n 'Action to specify what pull request data needs to be retrieved from GitHub',\n ),\n pull_number: integerSchema('Pull request number'),\n ref: stringSchema('Git reference to inspect. Required for get_status and get_check_runs'),\n cursor: stringSchema('Cursor for review comment pagination'),\n ...pageProperties,\n },\n ['method', 'pull_number'],\n {\n oneOf: [\n methodRequiredSchema('get', []),\n methodRequiredSchema('get_diff', []),\n methodRequiredSchema('get_status', ['ref']),\n methodRequiredSchema('get_files', []),\n methodRequiredSchema('get_commits', []),\n methodRequiredSchema('get_review_comments', []),\n methodRequiredSchema('get_reviews', []),\n methodRequiredSchema('get_comments', []),\n methodRequiredSchema('get_check_runs', ['ref']),\n ],\n },\n ),\n outputSchema: openObjectSchema('Pull request read result'),\n }),\n tool({\n id: 'list_pull_requests',\n category: 'pull_requests',\n description:\n 'List pull requests in a GitHub repository. If the user specifies an author, then do not use this tool and use the search_pull_requests tool instead.',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.pullRequestsRead,\n inputSchema: repositoryInputSchema({\n state: enumSchema(['open', 'closed', 'all'], 'Filter by state'),\n head: stringSchema('Filter by head user/org and branch'),\n base: stringSchema('Filter by base branch'),\n sort: enumSchema(['created', 'updated', 'popularity', 'long-running'], 'Sort by'),\n direction: enumSchema(['asc', 'desc'], 'Sort direction'),\n ...pageProperties,\n }),\n outputSchema: objectSchema(\n {pull_requests: arraySchema(openObjectSchema('GitHub pull request'))},\n ['pull_requests'],\n ),\n }),\n tool({\n id: 'search_pull_requests',\n category: 'pull_requests',\n description:\n 'Search for pull requests in GitHub repositories using issues search syntax already scoped to is:pr',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.pullRequestsRead,\n inputSchema: objectSchema(\n {\n query: stringSchema('Search query using GitHub pull request search syntax'),\n owner: stringSchema('Optional repository owner'),\n repo: stringSchema('Optional repository name'),\n sort: enumSchema(\n [\n 'comments',\n 'reactions',\n 'reactions-+1',\n 'reactions--1',\n 'reactions-smile',\n 'reactions-thinking_face',\n 'reactions-heart',\n 'reactions-tada',\n 'interactions',\n 'created',\n 'updated',\n ],\n 'Sort field',\n ),\n order: enumSchema(['asc', 'desc'], 'Sort order'),\n ...pageProperties,\n },\n ['query'],\n ),\n outputSchema: objectSchema(\n {pull_requests: arraySchema(openObjectSchema('GitHub pull request'))},\n ['pull_requests'],\n ),\n }),\n tool({\n id: 'create_pull_request',\n category: 'pull_requests',\n description: 'Create a new pull request in a GitHub repository.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n title: stringSchema('PR title'),\n body: stringSchema('PR description'),\n head: stringSchema('Branch containing changes'),\n base: stringSchema('Branch to merge into'),\n draft: booleanSchema('Create as draft PR'),\n maintainer_can_modify: booleanSchema('Allow maintainer edits'),\n reviewers: arraySchema(stringSchema('GitHub username or ORG/team-slug reviewer')),\n },\n ['title', 'head', 'base'],\n ),\n outputSchema: objectSchema({pull_request: openObjectSchema('Created GitHub pull request')}, [\n 'pull_request',\n ]),\n }),\n tool({\n id: 'update_pull_request',\n category: 'pull_requests',\n description: 'Update an existing pull request in a GitHub repository.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number to update'),\n title: stringSchema('New title'),\n body: stringSchema('New description'),\n state: enumSchema(['open', 'closed'], 'New state'),\n base: stringSchema('New base branch name'),\n maintainer_can_modify: booleanSchema('Allow maintainer edits'),\n reviewers: arraySchema(stringSchema('GitHub username or ORG/team-slug reviewer')),\n },\n ['pull_number'],\n ),\n outputSchema: objectSchema({pull_request: openObjectSchema('Updated GitHub pull request')}, [\n 'pull_request',\n ]),\n }),\n tool({\n id: 'add_reply_to_pull_request_comment',\n category: 'pull_requests',\n description:\n 'Add a reply and/or reaction to an existing pull request comment. This can create a new comment linked as a reply to the specified comment, add an emoji reaction to the specified comment, or do both. At least one of body or reaction is required.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number. Required when body is provided'),\n comment_id: integerSchema(\n 'The numeric ID of the pull request review comment to reply or react to',\n ),\n body: stringSchema('The text of the reply'),\n reaction: enumSchema(\n ['+1', '-1', 'laugh', 'confused', 'heart', 'hooray', 'rocket', 'eyes'],\n 'Emoji reaction to add',\n ),\n },\n ['comment_id'],\n {anyOf: [{required: ['pull_number', 'body']}, {required: ['reaction']}]},\n ),\n outputSchema: openObjectSchema('Pull request comment reply or reaction result'),\n }),\n tool({\n id: 'merge_pull_request',\n category: 'pull_requests',\n description: 'Merge a pull request in a GitHub repository.',\n sensitivity: 'write',\n sensitive: true,\n requiredScope: scopes.mergePullRequest,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number'),\n commit_title: stringSchema('Title for merge commit'),\n commit_message: stringSchema('Extra detail for merge commit'),\n merge_method: enumSchema(['merge', 'squash', 'rebase'], 'Merge method'),\n },\n ['pull_number'],\n ),\n outputSchema: objectSchema({merge: openObjectSchema('Merge result')}, ['merge']),\n }),\n tool({\n id: 'update_pull_request_branch',\n category: 'pull_requests',\n description:\n 'Update the branch of a pull request with the latest changes from the base branch.',\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number'),\n expected_head_sha: stringSchema(\"The expected SHA of the pull request's HEAD ref\"),\n },\n ['pull_number'],\n ),\n outputSchema: openObjectSchema('Pull request branch update result'),\n }),\n tool({\n id: 'pull_request_review_write',\n category: 'pull_requests',\n description: 'Create and/or submit, delete review of a pull request.',\n methods: pullRequestReviewWriteMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(\n pullRequestReviewWriteMethods,\n 'The write operation to perform on pull request review',\n ),\n pull_number: integerSchema('Pull request number'),\n body: stringSchema('Review comment text'),\n event: enumSchema(['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], 'Review action to perform'),\n commit_id: stringSchema('SHA of commit to review'),\n },\n ['method', 'pull_number'],\n ),\n outputSchema: openObjectSchema('Pull request review write result'),\n }),\n tool({\n id: 'add_comment_to_pending_review',\n category: 'pull_requests',\n description:\n \"Add a review comment to the requester's latest pending pull request review. The comment remains part of that pending review until it is submitted; a pending review needs to already exist to call this.\",\n sensitivity: 'write',\n sensitive: false,\n requiredScope: scopes.pullRequestsWrite,\n inputSchema: repositoryInputSchema(\n {\n pull_number: integerSchema('Pull request number'),\n path: stringSchema('The relative path to the file that necessitates a comment'),\n body: stringSchema('The text of the review comment'),\n subject_type: enumSchema(['LINE', 'FILE'], 'The level at which the comment is targeted'),\n line: integerSchema('The line of the blob in the pull request diff'),\n side: enumSchema(['LEFT', 'RIGHT'], 'The side of the diff to comment on'),\n start_line: integerSchema('The first line of a multi-line comment range'),\n start_side: enumSchema(\n ['LEFT', 'RIGHT'],\n 'The starting side of a multi-line comment range',\n ),\n },\n ['pull_number', 'path', 'body'],\n ),\n outputSchema: openObjectSchema('Pending review comment result'),\n }),\n tool({\n id: 'actions_list',\n category: 'actions',\n description:\n 'Tools for listing GitHub Actions resources. Use this tool to list workflows in a repository, or list workflow runs, jobs, and artifacts for a specific workflow or workflow run.',\n methods: actionsListMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(actionsListMethods, 'The action to perform'),\n resource_id: stringSchema('The unique identifier of the resource'),\n workflow_runs_filter: openObjectSchema('Filters for workflow runs'),\n workflow_jobs_filter: openObjectSchema('Filters for workflow jobs'),\n ...pageProperties,\n },\n ['method'],\n ),\n outputSchema: openObjectSchema('Actions list result'),\n }),\n tool({\n id: 'actions_get',\n category: 'actions',\n description:\n 'Get details about specific GitHub Actions resources. Use this tool to get details about individual workflows, workflow runs, jobs, and artifacts by their unique IDs.',\n methods: actionsGetMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(actionsGetMethods, 'The method to execute'),\n resource_id: stringSchema('The unique identifier of the resource'),\n },\n ['method', 'resource_id'],\n ),\n outputSchema: openObjectSchema('Actions get result'),\n }),\n tool({\n id: 'actions_run_trigger',\n category: 'actions',\n description:\n 'Trigger GitHub Actions workflow operations, including running, re-running, cancelling workflow runs, and deleting workflow run logs.',\n methods: actionsRunTriggerMethods,\n inputSchema: repositoryInputSchema(\n {\n method: methodSchema(actionsRunTriggerMethods, 'The method to execute'),\n workflow_id: stringSchema(\n 'The workflow ID or workflow file name. Required for run_workflow',\n ),\n ref: stringSchema('The git reference for the workflow. Required for run_workflow'),\n inputs: openObjectSchema('Inputs the workflow accepts. Only used for run_workflow'),\n run_id: integerSchema(\n 'The ID of the workflow run. Required for all methods except run_workflow',\n ),\n },\n ['method'],\n {\n oneOf: [\n methodRequiredSchema('run_workflow', ['workflow_id', 'ref']),\n methodRequiredSchema('rerun_workflow_run', ['run_id']),\n methodRequiredSchema('rerun_failed_jobs', ['run_id']),\n methodRequiredSchema('cancel_workflow_run', ['run_id']),\n methodRequiredSchema('delete_workflow_run_logs', ['run_id']),\n ],\n },\n ),\n outputSchema: openObjectSchema('Actions run trigger result'),\n }),\n tool({\n id: 'get_job_logs',\n category: 'actions',\n description:\n 'Get logs for GitHub Actions workflow jobs. Use this tool to retrieve logs for a specific job or all failed jobs in a workflow run. For single job logs, provide job_id. For all failed jobs in a run, provide run_id with failed_only=true.',\n sensitivity: 'read',\n sensitive: false,\n requiredScope: scopes.actionsRead,\n inputSchema: repositoryInputSchema({\n job_id: numberSchema(\n 'The unique identifier of the workflow job. Required when getting logs for a single job.',\n ),\n run_id: numberSchema(\n 'The unique identifier of the workflow run. Required when failed_only is true to get logs for all failed jobs in the run.',\n ),\n failed_only: booleanSchema(\n 'When true, gets logs for all failed jobs in the workflow run specified by run_id. Requires run_id to be provided.',\n ),\n return_content: booleanSchema('Returns actual log content instead of URLs'),\n tail_lines: {\n ...numberSchema('Number of lines to return from the end of the log'),\n default: DEFAULT_JOB_LOG_TAIL_LINES,\n },\n }),\n outputSchema: openObjectSchema('GitHub Actions workflow job logs'),\n }),\n] as const satisfies readonly GithubAgentToolCatalogEntry[];\n\nexport type GithubAgentToolId = (typeof githubAgentToolCatalog)[number]['id'];\n\nexport function buildGithubAgentToolSelectionCatalog(\n catalog: readonly GithubAgentToolCatalogEntry[],\n): AgentToolSelectionCatalog {\n return {\n selectors: catalog.flatMap((entry): AgentToolSelector[] => {\n if (!entry.methods) {\n return [\n {\n token: entry.id,\n kind: 'standalone',\n sensitivity: entry.sensitivity,\n sensitive: entry.sensitive,\n },\n ];\n }\n\n return [\n {\n token: entry.id,\n kind: 'family',\n sensitivity: entry.sensitivity,\n sensitive: entry.sensitive,\n },\n {\n token: `${entry.id}.*`,\n kind: 'family_wildcard',\n sensitivity: entry.sensitivity,\n sensitive: entry.sensitive,\n },\n ...entry.methods.map((method) => ({\n token: `${entry.id}.${method.id}`,\n kind: 'method' as const,\n sensitivity: method.sensitivity,\n sensitive: method.sensitive,\n })),\n ];\n }),\n };\n}\n\nexport const githubAgentToolSelectionCatalog =\n buildGithubAgentToolSelectionCatalog(githubAgentToolCatalog);\n\nfunction tool(input: GithubAgentToolCatalogInput): GithubAgentToolCatalogEntry {\n if (!input.methods) {\n if (!input.sensitivity || input.sensitive === undefined || !input.requiredScope) {\n throw new Error(`GitHub agent tool ${input.id} is missing sensitivity or required scope`);\n }\n return {\n id: input.id,\n category: input.category,\n description: input.description,\n sensitivity: input.sensitivity,\n sensitive: input.sensitive,\n requiredScope: input.requiredScope,\n inputSchema: input.inputSchema,\n outputSchema: input.outputSchema,\n };\n }\n\n return {\n id: input.id,\n category: input.category,\n description: input.description,\n sensitivity: input.methods.some((candidate) => candidate.sensitivity === 'write')\n ? 'write'\n : 'read',\n sensitive: input.methods.some((candidate) => candidate.sensitive),\n requiredScope: unionRequiredScopes(input.methods),\n inputSchema: input.inputSchema,\n outputSchema: input.outputSchema,\n methods: input.methods,\n };\n}\n\nfunction method(\n id: string,\n description: string,\n sensitivity: GithubAgentToolSensitivity,\n sensitive: boolean,\n requiredScope: GithubAgentToolRequiredScope,\n): GithubAgentToolCatalogMethod {\n return {id, description, sensitivity, sensitive, requiredScope};\n}\n\nfunction unionRequiredScopes(\n methods: readonly GithubAgentToolCatalogMethod[],\n): GithubAgentToolRequiredScope {\n const byPermission = new Map<GithubAgentToolPermission, GithubAgentToolPermissionAccess>();\n\n for (const {requiredScope} of methods) {\n for (const {permission, access} of requiredScope) {\n if (byPermission.get(permission) === 'write') continue;\n byPermission.set(permission, access);\n }\n }\n\n return [...byPermission.entries()].map(([permission, access]) => ({permission, access}));\n}\n\nfunction repositoryInputSchema(\n properties: Record<string, AgentToolJsonSchema> = {},\n required: string[] = [],\n extraSchema: Partial<AgentToolJsonSchema> = {},\n): AgentToolJsonSchema {\n return objectSchema(\n {...repositoryProperties, ...properties},\n ['owner', 'repo', ...required],\n extraSchema,\n );\n}\n\nfunction objectSchema(\n properties: Record<string, AgentToolJsonSchema>,\n required: string[] = [],\n extraSchema: Partial<AgentToolJsonSchema> = {},\n): AgentToolJsonSchema {\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n ...(required.length > 0 ? {required} : {}),\n ...extraSchema,\n };\n}\n\nfunction methodRequiredSchema(methodId: string, required: string[]): AgentToolJsonSchema {\n return {\n properties: {\n method: {const: methodId},\n },\n required,\n };\n}\n\nfunction openObjectSchema(description: string): AgentToolJsonSchema {\n return {type: 'object', description, additionalProperties: true};\n}\n\nfunction stringSchema(description?: string): AgentToolJsonSchema {\n return {type: 'string', ...(description ? {description} : {})};\n}\n\nfunction integerSchema(\n description?: string,\n options: {minimum?: number | undefined; maximum?: number | undefined} = {},\n): AgentToolJsonSchema {\n return {type: 'integer', ...(description ? {description} : {}), ...options};\n}\n\nfunction numberSchema(description?: string): AgentToolJsonSchema {\n return {type: 'number', ...(description ? {description} : {})};\n}\n\nfunction booleanSchema(description: string): AgentToolJsonSchema {\n return {type: 'boolean', description};\n}\n\nfunction enumSchema(values: string[], description: string): AgentToolJsonSchema {\n return {type: 'string', description, enum: values};\n}\n\nfunction methodSchema(\n methods: readonly GithubAgentToolCatalogMethod[],\n description: string,\n): AgentToolJsonSchema {\n return enumSchema(\n methods.map((candidate) => candidate.id),\n description,\n );\n}\n\nfunction arraySchema(items: AgentToolJsonSchema): AgentToolJsonSchema {\n return {type: 'array', items};\n}\n"],"names":["DEFAULT_JOB_LOG_TAIL_LINES","scopes","issuesRead","permission","access","issuesWrite","pullRequestsRead","pullRequestsWrite","actionsRead","actionsWrite","mergePullRequest","repositoryProperties","owner","stringSchema","repo","pageProperties","page","integerSchema","minimum","per_page","maximum","issueReadMethods","method","issueWriteMethods","subIssueWriteMethods","pullRequestReadMethods","pullRequestReviewWriteMethods","actionsListMethods","actionsGetMethods","actionsRunTriggerMethods","githubAgentToolCatalog","tool","id","category","description","methods","inputSchema","repositoryInputSchema","methodSchema","issue_number","outputSchema","openObjectSchema","sensitivity","sensitive","requiredScope","objectSchema","issue_types","arraySchema","state","enumSchema","labels","orderBy","direction","since","after","first","issues","query","sort","order","comment_id","body","reaction","anyOf","required","title","assignees","milestone","issue_type","state_reason","duplicate_of","sub_issue_id","replace_parent","booleanSchema","after_id","before_id","pull_number","ref","cursor","oneOf","methodRequiredSchema","head","base","pull_requests","draft","maintainer_can_modify","reviewers","pull_request","commit_title","commit_message","merge_method","merge","expected_head_sha","event","commit_id","path","subject_type","line","side","start_line","start_side","resource_id","workflow_runs_filter","workflow_jobs_filter","workflow_id","inputs","run_id","job_id","numberSchema","failed_only","return_content","tail_lines","default","buildGithubAgentToolSelectionCatalog","catalog","selectors","flatMap","entry","token","kind","map","githubAgentToolSelectionCatalog","input","undefined","Error","some","candidate","unionRequiredScopes","byPermission","Map","get","set","entries","properties","extraSchema","type","additionalProperties","length","methodId","const","options","values","enum","items"],"mappings":"AAiCA,OAAO,MAAMA,6BAA6B,IAAI;AAkC9C,MAAMC,SAAS;IACbC,YAAY;QAAC;YAACC,YAAY;YAAUC,QAAQ;QAAM;KAAE;IACpDC,aAAa;QAAC;YAACF,YAAY;YAAUC,QAAQ;QAAO;KAAE;IACtDE,kBAAkB;QAAC;YAACH,YAAY;YAAiBC,QAAQ;QAAM;KAAE;IACjEG,mBAAmB;QAAC;YAACJ,YAAY;YAAiBC,QAAQ;QAAO;KAAE;IACnEI,aAAa;QAAC;YAACL,YAAY;YAAWC,QAAQ;QAAM;KAAE;IACtDK,cAAc;QAAC;YAACN,YAAY;YAAWC,QAAQ;QAAO;KAAE;IACxDM,kBAAkB;QAChB;YAACP,YAAY;YAAiBC,QAAQ;QAAO;QAC7C;YAACD,YAAY;YAAYC,QAAQ;QAAO;KACzC;AACH;AAEA,MAAMO,uBAAuB;IAC3BC,OAAOC,aAAa;IACpBC,MAAMD,aAAa;AACrB;AAEA,MAAME,iBAAiB;IACrBC,MAAMC,cAAc,8BAA8B;QAACC,SAAS;IAAC;IAC7DC,UAAUF,cAAc,mCAAmC;QAACC,SAAS;QAAGE,SAAS;IAAG;AACtF;AAEA,MAAMC,mBAAmB;IACvBC,OAAO,OAAO,2CAA2C,QAAQ,OAAOrB,OAAOC,UAAU;IACzFoB,OAAO,gBAAgB,qCAAqC,QAAQ,OAAOrB,OAAOC,UAAU;IAC5FoB,OACE,kBACA,wCACA,QACA,OACArB,OAAOC,UAAU;IAEnBoB,OACE,cACA,8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G;IAAW;AACtC;AAEA,SAASe,WAAW4F,MAAgB,EAAE3G,WAAmB;IACvD,OAAO;QAACqG,MAAM;QAAUrG;QAAa4G,MAAMD;IAAM;AACnD;AAEA,SAASvG,aACPH,OAAgD,EAChDD,WAAmB;IAEnB,OAAOe,WACLd,QAAQqF,GAAG,CAAC,CAACM,YAAcA,UAAU9F,EAAE,GACvCE;AAEJ;AAEA,SAASa,YAAYgG,KAA0B;IAC7C,OAAO;QAACR,MAAM;QAASQ;IAAK;AAC9B"}
|
|
@@ -6,6 +6,7 @@ export declare function recordInstallationTokenMint(params: {
|
|
|
6
6
|
outcome: 'success' | 'failure';
|
|
7
7
|
durationMs: number;
|
|
8
8
|
}): void;
|
|
9
|
+
export declare function recordInstallationTokenFormat(token: string): void;
|
|
9
10
|
export declare function recordInstallationTokenLockWait(durationMs: number): void;
|
|
10
11
|
export declare function recordInstallationTokenBackoff(params: {
|
|
11
12
|
reason: IntegrationProviderErrorReason;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/metrics/instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,8BAA8B,CAAC;AAEjF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/metrics/instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,8BAA8B,CAAC;AAEjF,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,qCAAqC,CAAC;AAKxE,MAAM,MAAM,oCAAoC,GAC5C,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,cAAc,GACd,SAAS,GACT,gBAAgB,CAAC;AAqDrB,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,oCAAoC,GAAG,IAAI,CAEjG;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAKP;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAOjE;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAExE;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACrD,MAAM,EAAE,8BAA8B,CAAC;IACvC,KAAK,EAAE,cAAc,CAAC;CACvB,GAAG,IAAI,CAEP"}
|
package/dist/metrics/instance.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { instanceMetrics } from '@shipfox/node-opentelemetry';
|
|
2
|
+
import { config } from '#config.js';
|
|
2
3
|
const meter = instanceMetrics.getMeter('github');
|
|
3
4
|
const installationTokenLookupCount = meter.createCounter('github_installation_token_lookup', {
|
|
4
5
|
description: 'GitHub installation token cache lookups by serving outcome'
|
|
@@ -23,6 +24,9 @@ const installationTokenMintDuration = meter.createHistogram('github_installation
|
|
|
23
24
|
]
|
|
24
25
|
}
|
|
25
26
|
});
|
|
27
|
+
const installationTokenFormatCount = meter.createCounter('github_installation_token_format', {
|
|
28
|
+
description: 'GitHub installation tokens observed by format and requested override'
|
|
29
|
+
});
|
|
26
30
|
const installationTokenLockWaitDuration = meter.createHistogram('github_installation_token_lock_wait_duration', {
|
|
27
31
|
description: 'GitHub installation token advisory lock acquire and hold duration',
|
|
28
32
|
unit: 'ms',
|
|
@@ -65,11 +69,26 @@ export function recordInstallationTokenMint(params) {
|
|
|
65
69
|
installationTokenMintDuration.record(params.durationMs);
|
|
66
70
|
});
|
|
67
71
|
}
|
|
72
|
+
export function recordInstallationTokenFormat(token) {
|
|
73
|
+
recordMetric(()=>{
|
|
74
|
+
installationTokenFormatCount.add(1, {
|
|
75
|
+
format: installationTokenFormat(token),
|
|
76
|
+
override: config.GITHUB_INSTALLATION_TOKEN_FORMAT_OVERRIDE ?? 'absent'
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
68
80
|
export function recordInstallationTokenLockWait(durationMs) {
|
|
69
81
|
recordMetric(()=>installationTokenLockWaitDuration.record(durationMs));
|
|
70
82
|
}
|
|
71
83
|
export function recordInstallationTokenBackoff(params) {
|
|
72
84
|
recordMetric(()=>installationTokenBackoffCount.add(1, params));
|
|
73
85
|
}
|
|
86
|
+
function installationTokenFormat(token) {
|
|
87
|
+
if (!token.startsWith('ghs_')) return 'unknown';
|
|
88
|
+
const dotCount = token.slice(4).split('.').length - 1;
|
|
89
|
+
if (dotCount === 2) return 'stateless';
|
|
90
|
+
if (dotCount === 0) return 'stateful';
|
|
91
|
+
return 'unknown';
|
|
92
|
+
}
|
|
74
93
|
|
|
75
94
|
//# sourceMappingURL=instance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/metrics/instance.ts"],"sourcesContent":["import type {IntegrationProviderErrorReason} from '@shipfox/api-integration-spi';\nimport {instanceMetrics} from '@shipfox/node-opentelemetry';\nimport type {MintErrorClass} from '#api/installation-token-envelope.js';\n\nconst meter = instanceMetrics.getMeter('github');\n\nexport type GithubInstallationTokenLookupOutcome =\n | 'ram-hit'\n | 'db-hit'\n | 'minted'\n | 'served-stale'\n | 'backoff'\n | 'contended-poll';\n\nconst installationTokenLookupCount = meter.createCounter<{\n outcome: GithubInstallationTokenLookupOutcome;\n}>('github_installation_token_lookup', {\n description: 'GitHub installation token cache lookups by serving outcome',\n});\n\nconst installationTokenMintCount = meter.createCounter<{outcome: 'success' | 'failure'}>(\n 'github_installation_token_mint',\n {description: 'GitHub installation token mint attempts by outcome'},\n);\n\nconst installationTokenMintDuration = meter.createHistogram<Record<string, never>>(\n 'github_installation_token_mint_duration',\n {\n description: 'GitHub installation token mint duration',\n unit: 'ms',\n advice: {explicitBucketBoundaries: [10, 50, 100, 250, 500, 1000, 2500, 5000, 10000]},\n },\n);\n\nconst installationTokenLockWaitDuration = meter.createHistogram<Record<string, never>>(\n 'github_installation_token_lock_wait_duration',\n {\n description: 'GitHub installation token advisory lock acquire and hold duration',\n unit: 'ms',\n advice: {explicitBucketBoundaries: [0, 1, 5, 10, 25, 50, 100, 250, 500, 1000, 5000]},\n },\n);\n\nconst installationTokenBackoffCount = meter.createCounter<{\n reason: IntegrationProviderErrorReason;\n class: MintErrorClass;\n}>('github_installation_token_backoff', {\n description: 'GitHub installation token mint backoff activations by reason and class',\n});\n\nfunction recordMetric(record: () => void): void {\n try {\n record();\n } catch {\n // Metrics must not affect GitHub provider outcomes.\n }\n}\n\nexport function recordInstallationTokenLookup(outcome: GithubInstallationTokenLookupOutcome): void {\n recordMetric(() => installationTokenLookupCount.add(1, {outcome}));\n}\n\nexport function recordInstallationTokenMint(params: {\n outcome: 'success' | 'failure';\n durationMs: number;\n}): void {\n recordMetric(() => {\n installationTokenMintCount.add(1, {outcome: params.outcome});\n installationTokenMintDuration.record(params.durationMs);\n });\n}\n\nexport function recordInstallationTokenLockWait(durationMs: number): void {\n recordMetric(() => installationTokenLockWaitDuration.record(durationMs));\n}\n\nexport function recordInstallationTokenBackoff(params: {\n reason: IntegrationProviderErrorReason;\n class: MintErrorClass;\n}): void {\n recordMetric(() => installationTokenBackoffCount.add(1, params));\n}\n"],"names":["instanceMetrics","meter","getMeter","installationTokenLookupCount","createCounter","description","installationTokenMintCount","installationTokenMintDuration","createHistogram","unit","advice","explicitBucketBoundaries","installationTokenLockWaitDuration","installationTokenBackoffCount","recordMetric","record","recordInstallationTokenLookup","outcome","add","recordInstallationTokenMint","params","durationMs","recordInstallationTokenLockWait","recordInstallationTokenBackoff"],"mappings":"AACA,SAAQA,eAAe,QAAO,8BAA8B;
|
|
1
|
+
{"version":3,"sources":["../../src/metrics/instance.ts"],"sourcesContent":["import type {IntegrationProviderErrorReason} from '@shipfox/api-integration-spi';\nimport {instanceMetrics} from '@shipfox/node-opentelemetry';\nimport type {MintErrorClass} from '#api/installation-token-envelope.js';\nimport {config} from '#config.js';\n\nconst meter = instanceMetrics.getMeter('github');\n\nexport type GithubInstallationTokenLookupOutcome =\n | 'ram-hit'\n | 'db-hit'\n | 'minted'\n | 'served-stale'\n | 'backoff'\n | 'contended-poll';\n\nconst installationTokenLookupCount = meter.createCounter<{\n outcome: GithubInstallationTokenLookupOutcome;\n}>('github_installation_token_lookup', {\n description: 'GitHub installation token cache lookups by serving outcome',\n});\n\nconst installationTokenMintCount = meter.createCounter<{outcome: 'success' | 'failure'}>(\n 'github_installation_token_mint',\n {description: 'GitHub installation token mint attempts by outcome'},\n);\n\nconst installationTokenMintDuration = meter.createHistogram<Record<string, never>>(\n 'github_installation_token_mint_duration',\n {\n description: 'GitHub installation token mint duration',\n unit: 'ms',\n advice: {explicitBucketBoundaries: [10, 50, 100, 250, 500, 1000, 2500, 5000, 10000]},\n },\n);\n\nconst installationTokenFormatCount = meter.createCounter<{\n format: 'stateless' | 'stateful' | 'unknown';\n override: 'enabled' | 'disabled' | 'absent';\n}>('github_installation_token_format', {\n description: 'GitHub installation tokens observed by format and requested override',\n});\n\nconst installationTokenLockWaitDuration = meter.createHistogram<Record<string, never>>(\n 'github_installation_token_lock_wait_duration',\n {\n description: 'GitHub installation token advisory lock acquire and hold duration',\n unit: 'ms',\n advice: {explicitBucketBoundaries: [0, 1, 5, 10, 25, 50, 100, 250, 500, 1000, 5000]},\n },\n);\n\nconst installationTokenBackoffCount = meter.createCounter<{\n reason: IntegrationProviderErrorReason;\n class: MintErrorClass;\n}>('github_installation_token_backoff', {\n description: 'GitHub installation token mint backoff activations by reason and class',\n});\n\nfunction recordMetric(record: () => void): void {\n try {\n record();\n } catch {\n // Metrics must not affect GitHub provider outcomes.\n }\n}\n\nexport function recordInstallationTokenLookup(outcome: GithubInstallationTokenLookupOutcome): void {\n recordMetric(() => installationTokenLookupCount.add(1, {outcome}));\n}\n\nexport function recordInstallationTokenMint(params: {\n outcome: 'success' | 'failure';\n durationMs: number;\n}): void {\n recordMetric(() => {\n installationTokenMintCount.add(1, {outcome: params.outcome});\n installationTokenMintDuration.record(params.durationMs);\n });\n}\n\nexport function recordInstallationTokenFormat(token: string): void {\n recordMetric(() => {\n installationTokenFormatCount.add(1, {\n format: installationTokenFormat(token),\n override: config.GITHUB_INSTALLATION_TOKEN_FORMAT_OVERRIDE ?? 'absent',\n });\n });\n}\n\nexport function recordInstallationTokenLockWait(durationMs: number): void {\n recordMetric(() => installationTokenLockWaitDuration.record(durationMs));\n}\n\nexport function recordInstallationTokenBackoff(params: {\n reason: IntegrationProviderErrorReason;\n class: MintErrorClass;\n}): void {\n recordMetric(() => installationTokenBackoffCount.add(1, params));\n}\n\nfunction installationTokenFormat(token: string): 'stateless' | 'stateful' | 'unknown' {\n if (!token.startsWith('ghs_')) return 'unknown';\n const dotCount = token.slice(4).split('.').length - 1;\n if (dotCount === 2) return 'stateless';\n if (dotCount === 0) return 'stateful';\n return 'unknown';\n}\n"],"names":["instanceMetrics","config","meter","getMeter","installationTokenLookupCount","createCounter","description","installationTokenMintCount","installationTokenMintDuration","createHistogram","unit","advice","explicitBucketBoundaries","installationTokenFormatCount","installationTokenLockWaitDuration","installationTokenBackoffCount","recordMetric","record","recordInstallationTokenLookup","outcome","add","recordInstallationTokenMint","params","durationMs","recordInstallationTokenFormat","token","format","installationTokenFormat","override","GITHUB_INSTALLATION_TOKEN_FORMAT_OVERRIDE","recordInstallationTokenLockWait","recordInstallationTokenBackoff","startsWith","dotCount","slice","split","length"],"mappings":"AACA,SAAQA,eAAe,QAAO,8BAA8B;AAE5D,SAAQC,MAAM,QAAO,aAAa;AAElC,MAAMC,QAAQF,gBAAgBG,QAAQ,CAAC;AAUvC,MAAMC,+BAA+BF,MAAMG,aAAa,CAErD,oCAAoC;IACrCC,aAAa;AACf;AAEA,MAAMC,6BAA6BL,MAAMG,aAAa,CACpD,kCACA;IAACC,aAAa;AAAoD;AAGpE,MAAME,gCAAgCN,MAAMO,eAAe,CACzD,2CACA;IACEH,aAAa;IACbI,MAAM;I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