import type { GitLabRemoveMemberParams, GitLabRemoveMemberResponse } from '@/tools/gitlab/types' import { getGitLabApiBase, getGitLabResourcePath } from '@/tools/gitlab/utils' import type { ToolConfig } from '@/tools/types' export const gitlabRemoveMemberTool: ToolConfig< GitLabRemoveMemberParams, GitLabRemoveMemberResponse > = { id: 'gitlab_remove_member', name: 'GitLab Remove Member', description: 'Remove a member from 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 ID of the member to remove', }, skipSubresources: { type: 'boolean', required: false, visibility: 'user-or-llm', description: 'Skip deleting the member from subgroups and projects below the target (defaults to false)', }, unassignIssuables: { type: 'boolean', required: false, visibility: 'user-or-llm', description: 'Unassign the member from all issues and merge requests in the target (defaults to false)', }, }, request: { url: (params) => { const resourcePath = getGitLabResourcePath(params.resourceType, params.resourceId) const queryParams = new URLSearchParams() if (params.skipSubresources) queryParams.append('skip_subresources', 'true') if (params.unassignIssuables) queryParams.append('unassign_issuables', 'true') const query = queryParams.toString() return `${getGitLabApiBase(params.host)}/${resourcePath}/members/${params.userId}${query ? `?${query}` : ''}` }, 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 member was removed successfully', }, }, }