-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathcreate_user.ts
More file actions
127 lines (118 loc) · 3.55 KB
/
Copy pathcreate_user.ts
File metadata and controls
127 lines (118 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import type { GitLabCreateUserParams, GitLabUserResponse } from '@/tools/gitlab/types'
import { getGitLabApiBase } from '@/tools/gitlab/utils'
import type { ToolConfig } from '@/tools/types'
export const gitlabCreateUserTool: ToolConfig<GitLabCreateUserParams, GitLabUserResponse> = {
id: 'gitlab_create_user',
name: 'GitLab Create User',
description:
'Create a new GitLab user. Requires an administrator token with admin_mode on the instance.',
version: '1.0.0',
params: {
accessToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'GitLab admin Personal Access Token (admin_mode)',
},
host: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Self-managed GitLab host (e.g. gitlab.example.com). Defaults to gitlab.com.',
},
email: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: "The user's email address",
},
username: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: "The user's username",
},
name: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: "The user's display name",
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: "The user's password. Omit and set resetPassword to email a reset link instead.",
},
resetPassword: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Send the user a password reset link instead of setting a password',
},
forceRandomPassword: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description:
'Set a random password without emailing a reset link (useful for SSO-only accounts). One of password, resetPassword, or forceRandomPassword is required.',
},
admin: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Whether the new user is an administrator',
},
skipConfirmation: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Skip email confirmation for the new user',
},
},
request: {
url: (params) => `${getGitLabApiBase(params.host)}/users`,
method: 'POST',
headers: (params) => ({
'Content-Type': 'application/json',
'PRIVATE-TOKEN': params.accessToken,
}),
body: (params) => {
const body: Record<string, unknown> = {
email: params.email,
username: params.username,
name: params.name,
}
if (params.password) body.password = params.password
if (params.resetPassword !== undefined) body.reset_password = params.resetPassword
if (params.forceRandomPassword !== undefined)
body.force_random_password = params.forceRandomPassword
if (params.admin !== undefined) body.admin = params.admin
if (params.skipConfirmation !== undefined) body.skip_confirmation = params.skipConfirmation
return body
},
},
transformResponse: async (response) => {
if (!response.ok) {
const errorText = await response.text()
return {
success: false,
error: `GitLab API error: ${response.status} ${errorText}`,
output: {},
}
}
const user = await response.json()
return {
success: true,
output: {
user,
},
}
},
outputs: {
user: {
type: 'object',
description: 'The created user',
},
},
}