import type { GitLabDenyAccessRequestParams, GitLabDenyAccessRequestResponse, } from '@/tools/gitlab/types' import { getGitLabApiBase, getGitLabResourcePath } from '@/tools/gitlab/utils' import type { ToolConfig } from '@/tools/types' export const gitlabDenyAccessRequestTool: ToolConfig< GitLabDenyAccessRequestParams, GitLabDenyAccessRequestResponse > = { id: 'gitlab_deny_access_request', name: 'GitLab Deny Access Request', description: 'Deny (delete) a pending access request for a GitLab project or group', version: '1.0.0', params: { accessToken: { type: 'string', required: true, visibility: 'user-only', description: 'GitLab Personal Access Token', }, host: { type: 'string', required: false, visibility: 'user-only', description: 'Self-managed GitLab host (e.g. gitlab.example.com). Defaults to gitlab.com.', }, resourceType: { type: 'string', required: true, visibility: 'user-or-llm', description: "Whether the resource is a 'project' or a 'group'", }, resourceId: { type: 'string', required: true, visibility: 'user-or-llm', description: 'Project or group ID or path (e.g. mygroup/myproject)', }, userId: { type: 'number', required: true, visibility: 'user-or-llm', description: 'The user ID of the access requester', }, }, request: { url: (params) => { const resourcePath = getGitLabResourcePath(params.resourceType, params.resourceId) return `${getGitLabApiBase(params.host)}/${resourcePath}/access_requests/${params.userId}` }, method: 'DELETE', headers: (params) => ({ 'PRIVATE-TOKEN': params.accessToken, }), }, transformResponse: async (response) => { if (!response.ok) { const errorText = await response.text() return { success: false, error: `GitLab API error: ${response.status} ${errorText}`, output: {}, } } return { success: true, output: { success: true, }, } }, outputs: { success: { type: 'boolean', description: 'Whether the access request was denied successfully', }, }, }