@clerk/agent-toolkit 0.0.7-snapshot.v20250310161610 → 0.0.7
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/README.md +77 -9
- package/dist/ai-sdk/index.d.ts +2 -2
- package/dist/ai-sdk/index.js +11 -11
- package/dist/ai-sdk/index.js.map +1 -1
- package/dist/chunk-C5UZKCGR.js +30 -0
- package/dist/chunk-C5UZKCGR.js.map +1 -0
- package/dist/{chunk-SEOMNBNU.js → chunk-G2DZO54M.js} +151 -135
- package/dist/chunk-G2DZO54M.js.map +1 -0
- package/dist/chunk-N7G6S5SC.js +29 -0
- package/dist/chunk-N7G6S5SC.js.map +1 -0
- package/dist/clerk-tool-DBP9CCv4.d.ts +73 -0
- package/dist/{index-BtdcFG6Y.d.ts → index-C2ey_IXV.d.ts} +2 -68
- package/dist/langchain/index.d.ts +2 -2
- package/dist/langchain/index.js +12 -12
- package/dist/langchain/index.js.map +1 -1
- package/dist/modelcontextprotocol/index.d.ts +22 -0
- package/dist/modelcontextprotocol/index.js +8 -0
- package/dist/modelcontextprotocol/index.js.map +1 -0
- package/dist/modelcontextprotocol/local-server.d.ts +1 -0
- package/dist/modelcontextprotocol/local-server.js +49 -0
- package/dist/modelcontextprotocol/local-server.js.map +1 -0
- package/package.json +24 -11
- package/dist/chunk-SEOMNBNU.js.map +0 -1
|
@@ -9,7 +9,7 @@ var API_URL = getEnvVariable("CLERK_API_URL") || apiUrlFromPublishableKey(PUBLIS
|
|
|
9
9
|
var JWT_KEY = getEnvVariable("CLERK_JWT_KEY") || "";
|
|
10
10
|
var SDK_METADATA = {
|
|
11
11
|
name: "@clerk/agent-toolkit",
|
|
12
|
-
version: "0.0.7
|
|
12
|
+
version: "0.0.7",
|
|
13
13
|
environment: getEnvVariable("NODE_ENV")
|
|
14
14
|
};
|
|
15
15
|
var clerkClient = createClerkClient({
|
|
@@ -17,28 +17,14 @@ var clerkClient = createClerkClient({
|
|
|
17
17
|
apiUrl: API_URL,
|
|
18
18
|
apiVersion: API_VERSION,
|
|
19
19
|
jwtKey: JWT_KEY,
|
|
20
|
-
userAgent: `${"@clerk/agent-toolkit"}@${"0.0.7
|
|
20
|
+
userAgent: `${"@clerk/agent-toolkit"}@${"0.0.7"}`,
|
|
21
21
|
sdkMetadata: SDK_METADATA
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
// src/lib/constants.ts
|
|
25
|
-
var
|
|
26
|
-
allowPrivateMetadata: false
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// src/lib/inject-session-claims.ts
|
|
30
|
-
var injectSessionClaims = (context) => (prompt) => {
|
|
31
|
-
if (!context.sessionClaims && !context.userId) {
|
|
32
|
-
return prompt;
|
|
33
|
-
}
|
|
34
|
-
const lines = [];
|
|
35
|
-
lines.push(`# Signed-in user info:`);
|
|
36
|
-
lines.push(
|
|
37
|
-
context.sessionClaims?.sub || context.userId ? `Your userId is ${context.sessionClaims?.sub || context.userId}` : ""
|
|
38
|
-
);
|
|
39
|
-
lines.push(context.sessionClaims?.sid ? `Your sessionId is ${context.sessionClaims?.sid}` : "");
|
|
40
|
-
lines.push(prompt);
|
|
41
|
-
return lines.filter(Boolean).join("\n");
|
|
25
|
+
var defaultCreateClerkToolkitParams = {
|
|
26
|
+
allowPrivateMetadata: false,
|
|
27
|
+
clerkClient
|
|
42
28
|
};
|
|
43
29
|
|
|
44
30
|
// src/lib/utils.ts
|
|
@@ -61,15 +47,41 @@ var prunePrivateData = (context, o) => {
|
|
|
61
47
|
}
|
|
62
48
|
return o;
|
|
63
49
|
};
|
|
50
|
+
var filterTools = (tools2, pattern) => {
|
|
51
|
+
if (!pattern || pattern.length === 0) {
|
|
52
|
+
throw new Error("No pattern specified");
|
|
53
|
+
}
|
|
54
|
+
if (pattern === "*") {
|
|
55
|
+
return Object.values(tools2).flatMap((category2) => Object.values(category2));
|
|
56
|
+
}
|
|
57
|
+
const validPattern = /^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_*]+)?$/;
|
|
58
|
+
if (!validPattern.test(pattern)) {
|
|
59
|
+
throw new Error("Invalid pattern");
|
|
60
|
+
}
|
|
61
|
+
const [category, tool] = pattern.split(".");
|
|
62
|
+
if (!category || category && !tools2[category]) {
|
|
63
|
+
throw new Error(`Tool category not found: ${category}`);
|
|
64
|
+
}
|
|
65
|
+
if (category && tool === "*" || category && !tool) {
|
|
66
|
+
return Object.values(tools2[category]);
|
|
67
|
+
}
|
|
68
|
+
if (category && tool && !tools2[category][tool]) {
|
|
69
|
+
throw new Error(`Tool not found: ${tool}`);
|
|
70
|
+
}
|
|
71
|
+
return [tools2[category][tool]];
|
|
72
|
+
};
|
|
64
73
|
|
|
65
74
|
// src/lib/tools/invitations.ts
|
|
66
|
-
import { z } from "zod";
|
|
75
|
+
import { z as z2 } from "zod";
|
|
67
76
|
|
|
68
77
|
// src/lib/clerk-tool.ts
|
|
78
|
+
import { z } from "zod";
|
|
69
79
|
var trimLines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
|
|
70
|
-
var ClerkTool = (
|
|
71
|
-
const
|
|
72
|
-
const
|
|
80
|
+
var ClerkTool = (_params) => {
|
|
81
|
+
const { execute, ...params } = _params;
|
|
82
|
+
const parameters = params.parameters ? params.parameters : z.object({});
|
|
83
|
+
const schemaEntries = Object.entries(parameters.shape);
|
|
84
|
+
const args = schemaEntries.length === 0 ? "Takes no arguments" : schemaEntries.map(([key, value]) => {
|
|
73
85
|
return `- ${key}: ${value.description || ""}`;
|
|
74
86
|
}).join("\n");
|
|
75
87
|
const description = trimLines(`
|
|
@@ -80,7 +92,15 @@ var ClerkTool = (params) => {
|
|
|
80
92
|
Arguments:
|
|
81
93
|
${args}
|
|
82
94
|
`);
|
|
83
|
-
return {
|
|
95
|
+
return {
|
|
96
|
+
...params,
|
|
97
|
+
parameters,
|
|
98
|
+
description,
|
|
99
|
+
bindExecute: (clerkClient2, params2) => {
|
|
100
|
+
const toolContext = { ...params2.authContext, allowPrivateMetadata: params2.allowPrivateMetadata };
|
|
101
|
+
return execute(clerkClient2, toolContext);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
84
104
|
};
|
|
85
105
|
|
|
86
106
|
// src/lib/tools/invitations.ts
|
|
@@ -98,14 +118,14 @@ var createInvitation = ClerkTool({
|
|
|
98
118
|
2. Creating a closed registration system where only invited users can join
|
|
99
119
|
3. Pre-configuring user attributes via publicMetadata before they sign up
|
|
100
120
|
`,
|
|
101
|
-
parameters:
|
|
102
|
-
emailAddress:
|
|
103
|
-
redirectUrl:
|
|
104
|
-
publicMetadata:
|
|
105
|
-
notify:
|
|
106
|
-
ignoreExisting:
|
|
121
|
+
parameters: z2.object({
|
|
122
|
+
emailAddress: z2.string().describe("(string): Email address to send the invitation to. Required."),
|
|
123
|
+
redirectUrl: z2.string().optional().describe("(string, optional): URL to redirect users to after they accept the invitation."),
|
|
124
|
+
publicMetadata: z2.record(z2.string(), z2.any()).optional().describe("(Record<string,any>, optional): Public metadata for the invitation."),
|
|
125
|
+
notify: z2.boolean().optional().describe("(boolean, optional): Whether to send an email notification. Defaults to true."),
|
|
126
|
+
ignoreExisting: z2.boolean().optional().describe("(boolean, optional): Whether to ignore if an invitation already exists. Defaults to false.")
|
|
107
127
|
}),
|
|
108
|
-
|
|
128
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
109
129
|
const res = await clerkClient2.invitations.createInvitation(params);
|
|
110
130
|
return prunePrivateData(context, res.raw);
|
|
111
131
|
}
|
|
@@ -124,10 +144,10 @@ var revokeInvitation = ClerkTool({
|
|
|
124
144
|
2. Revoking access when a prospective user should no longer be invited
|
|
125
145
|
3. Implementing invitation management controls for administrators
|
|
126
146
|
`,
|
|
127
|
-
parameters:
|
|
128
|
-
invitationId:
|
|
147
|
+
parameters: z2.object({
|
|
148
|
+
invitationId: z2.string().describe("(string): The ID of the invitation to revoke. Required.")
|
|
129
149
|
}),
|
|
130
|
-
|
|
150
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
131
151
|
const res = await clerkClient2.invitations.revokeInvitation(params.invitationId);
|
|
132
152
|
return prunePrivateData(context, res.raw);
|
|
133
153
|
}
|
|
@@ -138,7 +158,7 @@ var invitations = {
|
|
|
138
158
|
};
|
|
139
159
|
|
|
140
160
|
// src/lib/tools/organizations.ts
|
|
141
|
-
import { z as
|
|
161
|
+
import { z as z3 } from "zod";
|
|
142
162
|
var getOrganization = ClerkTool({
|
|
143
163
|
name: "getOrganization",
|
|
144
164
|
description: `
|
|
@@ -152,20 +172,20 @@ var getOrganization = ClerkTool({
|
|
|
152
172
|
2. Checking if an organization exists before performing operations on it
|
|
153
173
|
3. Retrieving organization metadata for application-specific functionality
|
|
154
174
|
`,
|
|
155
|
-
parameters:
|
|
156
|
-
organizationId:
|
|
157
|
-
slug:
|
|
175
|
+
parameters: z3.object({
|
|
176
|
+
organizationId: z3.string().optional().describe("(string, optional): The ID of the organization to retrieve. Required if slug is not provided."),
|
|
177
|
+
slug: z3.string().optional().describe(
|
|
158
178
|
"(string, optional): The slug of the organization to retrieve. Required if organizationId is not provided."
|
|
159
179
|
),
|
|
160
|
-
includeMembersCount:
|
|
180
|
+
includeMembersCount: z3.boolean().optional().describe("(boolean, optional): Whether to include the members count for the organization.")
|
|
161
181
|
}),
|
|
162
|
-
|
|
182
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
163
183
|
if (!params.organizationId && !params.slug) {
|
|
164
184
|
throw new Error("Either organizationId or slug must be provided");
|
|
165
185
|
}
|
|
166
186
|
const res = await clerkClient2.organizations.getOrganization({
|
|
167
187
|
...params,
|
|
168
|
-
organizationId: context.
|
|
188
|
+
organizationId: context.orgId || params.organizationId
|
|
169
189
|
});
|
|
170
190
|
return prunePrivateData(context, res.raw);
|
|
171
191
|
}
|
|
@@ -184,19 +204,19 @@ var createOrganization = ClerkTool({
|
|
|
184
204
|
2. Building a self-service organization creation flow
|
|
185
205
|
3. Migrating organizations from another system
|
|
186
206
|
`,
|
|
187
|
-
parameters:
|
|
188
|
-
name:
|
|
189
|
-
slug:
|
|
207
|
+
parameters: z3.object({
|
|
208
|
+
name: z3.string().describe("(string): The name of the new organization. Required."),
|
|
209
|
+
slug: z3.string().optional().describe(
|
|
190
210
|
"(string, optional): A URL-friendly identifier for the organization. If not provided, created from the name."
|
|
191
211
|
),
|
|
192
|
-
createdBy:
|
|
212
|
+
createdBy: z3.string().optional().describe(
|
|
193
213
|
"(string, optional): The user ID of the user creating the organization. Defaults to the current authenticated user."
|
|
194
214
|
),
|
|
195
|
-
maxAllowedMemberships:
|
|
196
|
-
publicMetadata:
|
|
197
|
-
privateMetadata:
|
|
215
|
+
maxAllowedMemberships: z3.number().optional().describe("(number, optional): Maximum number of members allowed in the organization."),
|
|
216
|
+
publicMetadata: z3.record(z3.string(), z3.any()).optional().describe("(Record<string,any>, optional): Public metadata for the organization."),
|
|
217
|
+
privateMetadata: z3.record(z3.string(), z3.any()).optional().describe("(Record<string,any>, optional): Private metadata for the organization (backend-only).")
|
|
198
218
|
}),
|
|
199
|
-
|
|
219
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
200
220
|
const { createdBy, ...createParams } = params;
|
|
201
221
|
const createParamsWithUser = createdBy || context.userId ? { ...createParams, createdBy: createdBy || context.userId } : createParams;
|
|
202
222
|
const res = await clerkClient2.organizations.createOrganization(createParamsWithUser);
|
|
@@ -217,20 +237,17 @@ var updateOrganization = ClerkTool({
|
|
|
217
237
|
2. Changing the maximum allowed memberships
|
|
218
238
|
3. Updating multiple organization attributes at once
|
|
219
239
|
`,
|
|
220
|
-
parameters:
|
|
221
|
-
organizationId:
|
|
222
|
-
name:
|
|
223
|
-
slug:
|
|
224
|
-
maxAllowedMemberships:
|
|
225
|
-
publicMetadata:
|
|
226
|
-
privateMetadata:
|
|
240
|
+
parameters: z3.object({
|
|
241
|
+
organizationId: z3.string().describe("(string): The ID of the organization to update. Required."),
|
|
242
|
+
name: z3.string().optional().describe("(string, optional): New name for the organization."),
|
|
243
|
+
slug: z3.string().optional().describe("(string, optional): New slug for the organization."),
|
|
244
|
+
maxAllowedMemberships: z3.number().optional().describe("(number, optional): New maximum number of members allowed."),
|
|
245
|
+
publicMetadata: z3.record(z3.string(), z3.any()).optional().describe("(Record<string,any>, optional): New public metadata for the organization."),
|
|
246
|
+
privateMetadata: z3.record(z3.string(), z3.any()).optional().describe("(Record<string,any>, optional): New private metadata for the organization (backend-only).")
|
|
227
247
|
}),
|
|
228
|
-
|
|
248
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
229
249
|
const { organizationId, ...updateParams } = params;
|
|
230
|
-
const res = await clerkClient2.organizations.updateOrganization(
|
|
231
|
-
context.organizationId || organizationId,
|
|
232
|
-
updateParams
|
|
233
|
-
);
|
|
250
|
+
const res = await clerkClient2.organizations.updateOrganization(context.orgId || organizationId, updateParams);
|
|
234
251
|
return prunePrivateData(context, res.raw);
|
|
235
252
|
}
|
|
236
253
|
});
|
|
@@ -251,19 +268,19 @@ var updateOrganizationMetadata = ClerkTool({
|
|
|
251
268
|
2. Keeping track of organization-specific application state
|
|
252
269
|
3. Adding custom attributes to organizations
|
|
253
270
|
`,
|
|
254
|
-
parameters:
|
|
255
|
-
organizationId:
|
|
256
|
-
publicMetadata:
|
|
271
|
+
parameters: z3.object({
|
|
272
|
+
organizationId: z3.string().describe("(string): The ID of the organization to update. Required."),
|
|
273
|
+
publicMetadata: z3.record(z3.string(), z3.any()).optional().describe(
|
|
257
274
|
"(Record<string,any>, optional): The public metadata to set or update. Use null values to remove specific keys."
|
|
258
275
|
),
|
|
259
|
-
privateMetadata:
|
|
276
|
+
privateMetadata: z3.record(z3.string(), z3.any()).optional().describe(
|
|
260
277
|
"(Record<string,any>, optional): The private metadata to set or update. Backend-only data. Use null values to remove specific keys."
|
|
261
278
|
)
|
|
262
279
|
}),
|
|
263
|
-
|
|
280
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
264
281
|
const { organizationId, ...metadataParams } = params;
|
|
265
282
|
const res = await clerkClient2.organizations.updateOrganizationMetadata(
|
|
266
|
-
context.
|
|
283
|
+
context.orgId || organizationId,
|
|
267
284
|
metadataParams
|
|
268
285
|
);
|
|
269
286
|
return prunePrivateData(context, res.raw);
|
|
@@ -283,11 +300,11 @@ var deleteOrganization = ClerkTool({
|
|
|
283
300
|
2. Allowing users to delete their own organizations
|
|
284
301
|
3. Administrative operations to remove unwanted organizations
|
|
285
302
|
`,
|
|
286
|
-
parameters:
|
|
287
|
-
organizationId:
|
|
303
|
+
parameters: z3.object({
|
|
304
|
+
organizationId: z3.string().describe("(string): The ID of the organization to delete. Required.")
|
|
288
305
|
}),
|
|
289
|
-
|
|
290
|
-
const res = await clerkClient2.organizations.deleteOrganization(context.
|
|
306
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
307
|
+
const res = await clerkClient2.organizations.deleteOrganization(context.orgId || params.organizationId);
|
|
291
308
|
return prunePrivateData(context, res.raw);
|
|
292
309
|
}
|
|
293
310
|
});
|
|
@@ -305,15 +322,15 @@ var createOrganizationMembership = ClerkTool({
|
|
|
305
322
|
2. Building administrative interfaces for member management
|
|
306
323
|
3. Migrating memberships from another system
|
|
307
324
|
`,
|
|
308
|
-
parameters:
|
|
309
|
-
organizationId:
|
|
310
|
-
userId:
|
|
311
|
-
role:
|
|
325
|
+
parameters: z3.object({
|
|
326
|
+
organizationId: z3.string().describe("(string): The ID of the organization to add the member to. Required."),
|
|
327
|
+
userId: z3.string().describe("(string): The ID of the user to add as a member. Required."),
|
|
328
|
+
role: z3.string().describe("(string): The role to assign to the user in the organization. Required.")
|
|
312
329
|
}),
|
|
313
|
-
|
|
330
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
314
331
|
const res = await clerkClient2.organizations.createOrganizationMembership({
|
|
315
332
|
...params,
|
|
316
|
-
organizationId: context.
|
|
333
|
+
organizationId: context.orgId || params.organizationId,
|
|
317
334
|
userId: context.userId || params.userId
|
|
318
335
|
});
|
|
319
336
|
return prunePrivateData(context, res.raw);
|
|
@@ -333,15 +350,15 @@ var updateOrganizationMembership = ClerkTool({
|
|
|
333
350
|
2. Building role management interfaces
|
|
334
351
|
3. Implementing admin-level controls for organization management
|
|
335
352
|
`,
|
|
336
|
-
parameters:
|
|
337
|
-
organizationId:
|
|
338
|
-
userId:
|
|
339
|
-
role:
|
|
353
|
+
parameters: z3.object({
|
|
354
|
+
organizationId: z3.string().describe("(string): The ID of the organization containing the membership. Required."),
|
|
355
|
+
userId: z3.string().describe("(string): The ID of the user whose membership is being updated. Required."),
|
|
356
|
+
role: z3.string().describe("(string): The new role to assign to the user. Required.")
|
|
340
357
|
}),
|
|
341
|
-
|
|
358
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
342
359
|
const res = await clerkClient2.organizations.updateOrganizationMembership({
|
|
343
360
|
...params,
|
|
344
|
-
organizationId: context.
|
|
361
|
+
organizationId: context.orgId || params.organizationId
|
|
345
362
|
});
|
|
346
363
|
return prunePrivateData(context, res.raw);
|
|
347
364
|
}
|
|
@@ -363,20 +380,20 @@ var updateOrganizationMembershipMetadata = ClerkTool({
|
|
|
363
380
|
2. Adding custom attributes to track member activity or status
|
|
364
381
|
3. Customizing a user's experience within a specific organization
|
|
365
382
|
`,
|
|
366
|
-
parameters:
|
|
367
|
-
organizationId:
|
|
368
|
-
userId:
|
|
369
|
-
publicMetadata:
|
|
383
|
+
parameters: z3.object({
|
|
384
|
+
organizationId: z3.string().describe("(string): The ID of the organization containing the membership. Required."),
|
|
385
|
+
userId: z3.string().describe("(string): The ID of the user whose membership metadata is being updated. Required."),
|
|
386
|
+
publicMetadata: z3.record(z3.string(), z3.any()).optional().describe(
|
|
370
387
|
"(Record<string,any>, optional): The public metadata to set or update. Use null values to remove specific keys."
|
|
371
388
|
),
|
|
372
|
-
privateMetadata:
|
|
389
|
+
privateMetadata: z3.record(z3.string(), z3.any()).optional().describe(
|
|
373
390
|
"(Record<string,any>, optional): The private metadata to set or update. Backend-only data. Use null values to remove specific keys."
|
|
374
391
|
)
|
|
375
392
|
}),
|
|
376
|
-
|
|
393
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
377
394
|
const res = await clerkClient2.organizations.updateOrganizationMembershipMetadata({
|
|
378
395
|
...params,
|
|
379
|
-
organizationId: context.
|
|
396
|
+
organizationId: context.orgId || params.organizationId
|
|
380
397
|
});
|
|
381
398
|
return prunePrivateData(context, res.raw);
|
|
382
399
|
}
|
|
@@ -395,11 +412,11 @@ var deleteOrganizationMembership = ClerkTool({
|
|
|
395
412
|
2. Building membership management interfaces with removal capability
|
|
396
413
|
3. Implementing self-service leave organization functionality
|
|
397
414
|
`,
|
|
398
|
-
parameters:
|
|
399
|
-
organizationId:
|
|
400
|
-
userId:
|
|
415
|
+
parameters: z3.object({
|
|
416
|
+
organizationId: z3.string().describe("(string): The ID of the organization to remove the member from. Required."),
|
|
417
|
+
userId: z3.string().describe("(string): The ID of the user to remove from the organization. Required.")
|
|
401
418
|
}),
|
|
402
|
-
|
|
419
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
403
420
|
const res = await clerkClient2.organizations.deleteOrganizationMembership({
|
|
404
421
|
...params,
|
|
405
422
|
userId: context.userId || params.userId
|
|
@@ -421,17 +438,17 @@ var createOrganizationInvitation = ClerkTool({
|
|
|
421
438
|
2. Implementing team expansion functionality
|
|
422
439
|
3. Creating administrative tools for organization growth
|
|
423
440
|
`,
|
|
424
|
-
parameters:
|
|
425
|
-
organizationId:
|
|
426
|
-
emailAddress:
|
|
427
|
-
role:
|
|
428
|
-
inviterUserId:
|
|
441
|
+
parameters: z3.object({
|
|
442
|
+
organizationId: z3.string().describe("(string): The ID of the organization to create an invitation for. Required."),
|
|
443
|
+
emailAddress: z3.string().describe("(string): Email address to send the invitation to. Required."),
|
|
444
|
+
role: z3.string().describe("(string): Role to assign to the user upon accepting the invitation. Required."),
|
|
445
|
+
inviterUserId: z3.string().optional().describe(
|
|
429
446
|
"(string, optional): User ID of the person sending the invitation. Defaults to the current authenticated user."
|
|
430
447
|
),
|
|
431
|
-
redirectUrl:
|
|
432
|
-
publicMetadata:
|
|
448
|
+
redirectUrl: z3.string().optional().describe("(string, optional): URL to redirect users to after they accept the invitation."),
|
|
449
|
+
publicMetadata: z3.record(z3.string(), z3.any()).optional().describe("(Record<string,any>, optional): Public metadata for the invitation.")
|
|
433
450
|
}),
|
|
434
|
-
|
|
451
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
435
452
|
const { inviterUserId, ...inviteParams } = params;
|
|
436
453
|
const inviteParamsWithUser = inviterUserId || context.userId ? { ...inviteParams, inviterUserId: inviterUserId || context.userId } : inviteParams;
|
|
437
454
|
const res = await clerkClient2.organizations.createOrganizationInvitation(inviteParamsWithUser);
|
|
@@ -452,14 +469,14 @@ var revokeOrganizationInvitation = ClerkTool({
|
|
|
452
469
|
2. Building invitation management interfaces with revocation capability
|
|
453
470
|
3. Implementing security measures to quickly revoke access
|
|
454
471
|
`,
|
|
455
|
-
parameters:
|
|
456
|
-
organizationId:
|
|
457
|
-
invitationId:
|
|
458
|
-
requestingUserId:
|
|
472
|
+
parameters: z3.object({
|
|
473
|
+
organizationId: z3.string().describe("(string): The ID of the organization containing the invitation. Required."),
|
|
474
|
+
invitationId: z3.string().describe("(string): The ID of the invitation to revoke. Required."),
|
|
475
|
+
requestingUserId: z3.string().optional().describe(
|
|
459
476
|
"(string, optional): User ID of the person revoking the invitation. Defaults to the current authenticated user."
|
|
460
477
|
)
|
|
461
478
|
}),
|
|
462
|
-
|
|
479
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
463
480
|
const { requestingUserId, ...revokeParams } = params;
|
|
464
481
|
const revokeParamsWithUser = requestingUserId || context.userId ? { ...revokeParams, requestingUserId: requestingUserId || context.userId } : revokeParams;
|
|
465
482
|
const res = await clerkClient2.organizations.revokeOrganizationInvitation(revokeParamsWithUser);
|
|
@@ -480,8 +497,8 @@ var organizations = {
|
|
|
480
497
|
revokeOrganizationInvitation
|
|
481
498
|
};
|
|
482
499
|
|
|
483
|
-
// src/lib/tools/
|
|
484
|
-
import { z as
|
|
500
|
+
// src/lib/tools/users.ts
|
|
501
|
+
import { z as z4 } from "zod";
|
|
485
502
|
var getUserId = ClerkTool({
|
|
486
503
|
name: "getUserId",
|
|
487
504
|
description: `
|
|
@@ -490,8 +507,8 @@ var getUserId = ClerkTool({
|
|
|
490
507
|
This tool takes no parameters and is the quickest way to check if a user is authenticated.
|
|
491
508
|
Example use case: When you need to verify if a user is logged in before performing user-specific operations.
|
|
492
509
|
`,
|
|
493
|
-
parameters:
|
|
494
|
-
|
|
510
|
+
parameters: z4.object({}),
|
|
511
|
+
execute: (clerkClient2, context) => () => {
|
|
495
512
|
return Promise.resolve(context.userId || null);
|
|
496
513
|
}
|
|
497
514
|
});
|
|
@@ -504,10 +521,10 @@ var getUser = ClerkTool({
|
|
|
504
521
|
If the userId parameter is not provided, it will use the current authenticated user's ID.
|
|
505
522
|
Example use case: When you need to display user profile information or check user attributes.
|
|
506
523
|
`,
|
|
507
|
-
parameters:
|
|
508
|
-
userId:
|
|
524
|
+
parameters: z4.object({
|
|
525
|
+
userId: z4.string().describe("(string): The userId of the User to retrieve.")
|
|
509
526
|
}),
|
|
510
|
-
|
|
527
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
511
528
|
const res = await clerkClient2.users.getUser(context.userId || params.userId);
|
|
512
529
|
return prunePrivateData(context, res.raw);
|
|
513
530
|
}
|
|
@@ -519,8 +536,8 @@ var getUserCount = ClerkTool({
|
|
|
519
536
|
Use this tool when you need to know the total number of users in the system.
|
|
520
537
|
This tool takes no parameters and is an efficient way to get just the count without retrieving user details.
|
|
521
538
|
`,
|
|
522
|
-
parameters:
|
|
523
|
-
|
|
539
|
+
parameters: z4.object({}),
|
|
540
|
+
execute: (clerkClient2, _) => async () => {
|
|
524
541
|
return await clerkClient2.users.getCount();
|
|
525
542
|
}
|
|
526
543
|
});
|
|
@@ -537,11 +554,11 @@ var updateUserPublicMetadata = ClerkTool({
|
|
|
537
554
|
|
|
538
555
|
Example use case: Storing user preferences, feature flags, or application-specific data that persists across sessions.
|
|
539
556
|
`,
|
|
540
|
-
parameters:
|
|
541
|
-
userId:
|
|
542
|
-
metadata:
|
|
557
|
+
parameters: z4.object({
|
|
558
|
+
userId: z4.string().describe("(string): The userId of the User to update."),
|
|
559
|
+
metadata: z4.record(z4.string(), z4.any()).describe("(Record<string,any>): The public metadata to set or update. Use null values to remove specific keys.")
|
|
543
560
|
}),
|
|
544
|
-
|
|
561
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
545
562
|
const { userId, metadata } = params;
|
|
546
563
|
const res = await clerkClient2.users.updateUserMetadata(context.userId || userId, { publicMetadata: metadata });
|
|
547
564
|
return prunePrivateData(context, res.raw);
|
|
@@ -561,11 +578,11 @@ var updateUserUnsafeMetadata = ClerkTool({
|
|
|
561
578
|
|
|
562
579
|
Example use case: Storing user data that should be modifiable from the frontend but not included in authentication tokens.
|
|
563
580
|
`,
|
|
564
|
-
parameters:
|
|
565
|
-
userId:
|
|
566
|
-
metadata:
|
|
581
|
+
parameters: z4.object({
|
|
582
|
+
userId: z4.string().describe("(string): The userId of the User to update."),
|
|
583
|
+
metadata: z4.record(z4.string(), z4.any()).describe("(Record<string,any>): The unsafe metadata to set or update. Use null values to remove specific keys.")
|
|
567
584
|
}),
|
|
568
|
-
|
|
585
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
569
586
|
const { userId, metadata } = params;
|
|
570
587
|
const res = await clerkClient2.users.updateUserMetadata(context.userId || userId, { unsafeMetadata: metadata });
|
|
571
588
|
return prunePrivateData(context, res.raw);
|
|
@@ -588,14 +605,14 @@ var updateUser = ClerkTool({
|
|
|
588
605
|
2. Enabling or disabling a user account
|
|
589
606
|
3. Setting a user's primary contact information
|
|
590
607
|
`,
|
|
591
|
-
parameters:
|
|
592
|
-
userId:
|
|
593
|
-
firstName:
|
|
594
|
-
lastName:
|
|
595
|
-
username:
|
|
596
|
-
profileImageUrl:
|
|
608
|
+
parameters: z4.object({
|
|
609
|
+
userId: z4.string().describe("(string): The userId of the User to update."),
|
|
610
|
+
firstName: z4.string().optional().describe("(string): New first name for the user"),
|
|
611
|
+
lastName: z4.string().optional().describe("(string): New last name for the user"),
|
|
612
|
+
username: z4.string().optional().describe("(string): New username for the user"),
|
|
613
|
+
profileImageUrl: z4.string().optional().describe("(string): URL for the user profile image")
|
|
597
614
|
}),
|
|
598
|
-
|
|
615
|
+
execute: (clerkClient2, context) => async (params) => {
|
|
599
616
|
const { userId, ...updateParams } = params;
|
|
600
617
|
const res = await clerkClient2.users.updateUser(context.userId || userId, updateParams);
|
|
601
618
|
return prunePrivateData(context, res.raw);
|
|
@@ -638,11 +655,10 @@ var flatTools = {
|
|
|
638
655
|
};
|
|
639
656
|
|
|
640
657
|
export {
|
|
641
|
-
|
|
642
|
-
defaultToolkitContext,
|
|
643
|
-
injectSessionClaims,
|
|
658
|
+
defaultCreateClerkToolkitParams,
|
|
644
659
|
shallowTransform,
|
|
660
|
+
filterTools,
|
|
645
661
|
tools,
|
|
646
662
|
flatTools
|
|
647
663
|
};
|
|
648
|
-
//# sourceMappingURL=chunk-
|
|
664
|
+
//# sourceMappingURL=chunk-G2DZO54M.js.map
|