@mastra/connect 0.7.0-alpha.0 → 1.0.0-alpha.2
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 +2 -2
- package/dist/channels.d.ts +4 -2
- package/dist/channels.d.ts.map +1 -1
- package/dist/client.d.ts +21 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/environment.d.ts.map +1 -1
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.cjs +458 -386
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +458 -386
- package/dist/index.js.map +1 -1
- package/dist/multi-connection.d.ts +1 -1
- package/dist/multi-connection.d.ts.map +1 -1
- package/dist/providers/channels.d.ts +5 -1
- package/dist/providers/channels.d.ts.map +1 -1
- package/dist/providers/clerk/tools/create-organization-domain.d.ts +9 -9
- package/dist/providers/clerk/tools/create-organization-domain.d.ts.map +1 -1
- package/dist/providers/clerk/tools/create-organization-invitation.d.ts +3 -3
- package/dist/providers/clerk/tools/create-user.d.ts.map +1 -1
- package/dist/providers/clerk/tools/delete-email-address.d.ts.map +1 -1
- package/dist/providers/clerk/tools/delete-organization-domain.d.ts.map +1 -1
- package/dist/providers/clerk/tools/delete-organization-membership.d.ts.map +1 -1
- package/dist/providers/clerk/tools/delete-organization-role.d.ts.map +1 -1
- package/dist/providers/clerk/tools/delete-phone-number.d.ts.map +1 -1
- package/dist/providers/clerk/tools/get-email-address.d.ts.map +1 -1
- package/dist/providers/clerk/tools/get-organization-invitation.d.ts +3 -3
- package/dist/providers/clerk/tools/get-organization-role.d.ts.map +1 -1
- package/dist/providers/clerk/tools/get-phone-number.d.ts.map +1 -1
- package/dist/providers/clerk/tools/get-session.d.ts +3 -3
- package/dist/providers/clerk/tools/get-session.d.ts.map +1 -1
- package/dist/providers/clerk/tools/list-organization-domains.d.ts +9 -9
- package/dist/providers/clerk/tools/list-organization-domains.d.ts.map +1 -1
- package/dist/providers/clerk/tools/list-organization-invitations.d.ts +3 -3
- package/dist/providers/clerk/tools/list-organization-invitations.d.ts.map +1 -1
- package/dist/providers/clerk/tools/list-organization-memberships.d.ts.map +1 -1
- package/dist/providers/clerk/tools/list-organization-roles.d.ts.map +1 -1
- package/dist/providers/clerk/tools/list-organizations.d.ts.map +1 -1
- package/dist/providers/clerk/tools/list-sessions.d.ts +3 -5
- package/dist/providers/clerk/tools/list-sessions.d.ts.map +1 -1
- package/dist/providers/clerk/tools/list-users.d.ts +12 -0
- package/dist/providers/clerk/tools/list-users.d.ts.map +1 -1
- package/dist/providers/clerk/tools/revoke-organization-invitation.d.ts +3 -3
- package/dist/providers/clerk/tools/revoke-session.d.ts +3 -3
- package/dist/providers/clerk/tools/revoke-session.d.ts.map +1 -1
- package/dist/providers/clerk/tools/update-organization-domain.d.ts +9 -9
- package/dist/providers/clerk/tools/update-organization-domain.d.ts.map +1 -1
- package/dist/providers/clerk/tools/update-organization-role.d.ts.map +1 -1
- package/dist/providers/clerk/tools/update-organization.d.ts +2 -0
- package/dist/providers/clerk/tools/update-organization.d.ts.map +1 -1
- package/dist/providers/clerk/tools/update-user.d.ts +10 -10
- package/dist/providers/clerk/tools/verify-organization-domain.d.ts +12 -7
- package/dist/providers/clerk/tools/verify-organization-domain.d.ts.map +1 -1
- package/dist/providers/discord/index.d.ts.map +1 -1
- package/dist/providers/discord/tools/_bot-token.d.ts +11 -0
- package/dist/providers/discord/tools/_bot-token.d.ts.map +1 -0
- package/dist/providers/discord/tools/add-guild-member-role.d.ts.map +1 -1
- package/dist/providers/discord/tools/create-channel.d.ts.map +1 -1
- package/dist/providers/discord/tools/create-message.d.ts.map +1 -1
- package/dist/providers/discord/tools/create-reaction.d.ts.map +1 -1
- package/dist/providers/discord/tools/create-role.d.ts.map +1 -1
- package/dist/providers/discord/tools/create-thread-from-message.d.ts.map +1 -1
- package/dist/providers/discord/tools/create-webhook.d.ts.map +1 -1
- package/dist/providers/discord/tools/delete-channel.d.ts.map +1 -1
- package/dist/providers/discord/tools/delete-guild-member.d.ts.map +1 -1
- package/dist/providers/discord/tools/delete-guild.d.ts.map +1 -1
- package/dist/providers/discord/tools/delete-message.d.ts.map +1 -1
- package/dist/providers/discord/tools/delete-reaction.d.ts.map +1 -1
- package/dist/providers/discord/tools/delete-role.d.ts.map +1 -1
- package/dist/providers/discord/tools/delete-webhook.d.ts.map +1 -1
- package/dist/providers/discord/tools/get-channel.d.ts.map +1 -1
- package/dist/providers/discord/tools/get-guild-member.d.ts.map +1 -1
- package/dist/providers/discord/tools/get-guild.d.ts.map +1 -1
- package/dist/providers/discord/tools/get-message.d.ts.map +1 -1
- package/dist/providers/discord/tools/get-role.d.ts.map +1 -1
- package/dist/providers/discord/tools/get-webhook.d.ts.map +1 -1
- package/dist/providers/discord/tools/list-channels.d.ts +2 -2
- package/dist/providers/discord/tools/list-channels.d.ts.map +1 -1
- package/dist/providers/discord/tools/list-guild-members.d.ts.map +1 -1
- package/dist/providers/discord/tools/list-guilds.d.ts.map +1 -1
- package/dist/providers/discord/tools/list-messages.d.ts.map +1 -1
- package/dist/providers/discord/tools/list-roles.d.ts.map +1 -1
- package/dist/providers/discord/tools/list-webhooks.d.ts.map +1 -1
- package/dist/providers/discord/tools/remove-guild-member-role.d.ts.map +1 -1
- package/dist/providers/discord/tools/update-channel.d.ts.map +1 -1
- package/dist/providers/discord/tools/update-guild-member.d.ts.map +1 -1
- package/dist/providers/discord/tools/update-guild.d.ts.map +1 -1
- package/dist/providers/discord/tools/update-message.d.ts.map +1 -1
- package/dist/providers/discord/tools/update-role.d.ts.map +1 -1
- package/dist/providers/discord/tools/update-webhook.d.ts.map +1 -1
- package/dist/providers/resend/tools/cancel-email.d.ts +2 -2
- package/dist/providers/resend/tools/get-email.d.ts +2 -2
- package/dist/providers/resend/tools/get-received-email.d.ts +2 -2
- package/dist/providers/resend/tools/get-template.d.ts +2 -2
- package/dist/providers/resend/tools/list-emails.d.ts +2 -2
- package/dist/providers/resend/tools/list-received-emails.d.ts +2 -2
- package/dist/providers/resend/tools/update-contact-topics.d.ts.map +1 -1
- package/dist/runtime/platform-proxy.d.ts.map +1 -1
- package/dist/tools.d.ts +12 -7
- package/dist/tools.d.ts.map +1 -1
- package/package.json +11 -7
package/dist/index.cjs
CHANGED
|
@@ -8,18 +8,56 @@ var MastraConnectError = class extends Error {
|
|
|
8
8
|
code;
|
|
9
9
|
status;
|
|
10
10
|
detail;
|
|
11
|
+
/**
|
|
12
|
+
* Axios-compatible alias for {@link status}. Generated provider tools come
|
|
13
|
+
* from upstream Nango templates whose error handlers check
|
|
14
|
+
* `error.response.status` (the axios/Nango SDK shape). Exposing the HTTP
|
|
15
|
+
* status under `response.status` as well lets that generated code work
|
|
16
|
+
* unchanged against the errors this package throws. Only set when the error
|
|
17
|
+
* carries an HTTP status.
|
|
18
|
+
*/
|
|
19
|
+
response;
|
|
11
20
|
constructor(code, message, options) {
|
|
12
21
|
super(message);
|
|
13
22
|
this.name = "MastraConnectError";
|
|
14
23
|
this.code = code;
|
|
15
24
|
this.status = options?.status;
|
|
16
25
|
this.detail = options?.detail ? truncate(options.detail) : void 0;
|
|
26
|
+
if (typeof options?.status === "number") this.response = { status: options.status };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* A caller configuration mistake (for example an unknown tool name in
|
|
31
|
+
* `requireApproval`) that must fail resolution instead of being downgraded
|
|
32
|
+
* to the resolver's warn-and-skip path, which exists for provider-side
|
|
33
|
+
* failures. Internal to the package: callers observe it as a regular
|
|
34
|
+
* `MastraConnectError` with code `invalid_options`.
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
var MastraConnectConfigError = class extends MastraConnectError {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super("invalid_options", message);
|
|
17
41
|
}
|
|
18
42
|
};
|
|
19
43
|
function truncate(text) {
|
|
20
44
|
return text.length > MAX_DETAIL_LENGTH ? `${text.slice(0, MAX_DETAIL_LENGTH)}…` : text;
|
|
21
45
|
}
|
|
22
46
|
/**
|
|
47
|
+
* Pulls the first human-readable message from an array of error entries. Many
|
|
48
|
+
* providers (Clerk, Linear's GraphQL envelope, Nango v2) return
|
|
49
|
+
* `{ errors: [{ message, long_message, code }] }`; surfacing the first message
|
|
50
|
+
* is the most useful detail without echoing the whole payload.
|
|
51
|
+
*/
|
|
52
|
+
function extractFirstArrayMessage(errors) {
|
|
53
|
+
for (const entry of errors) {
|
|
54
|
+
if (!entry || typeof entry !== "object") continue;
|
|
55
|
+
const record = entry;
|
|
56
|
+
const message = typeof record.long_message === "string" ? record.long_message : record.message;
|
|
57
|
+
if (typeof message === "string" && message) return message;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
23
61
|
* Extracts a human-readable detail string from an RFC-7807 problem JSON body
|
|
24
62
|
* (or a plain `{ error }` body) without echoing anything else from the response.
|
|
25
63
|
* Returns undefined when the body is not parseable JSON.
|
|
@@ -50,6 +88,14 @@ async function extractProblemDetail(response) {
|
|
|
50
88
|
};
|
|
51
89
|
}
|
|
52
90
|
}
|
|
91
|
+
if (Array.isArray(data.errors)) {
|
|
92
|
+
const message = extractFirstArrayMessage(data.errors);
|
|
93
|
+
if (message) return {
|
|
94
|
+
detail: truncate(message),
|
|
95
|
+
code,
|
|
96
|
+
isProblemJson
|
|
97
|
+
};
|
|
98
|
+
}
|
|
53
99
|
return {
|
|
54
100
|
code,
|
|
55
101
|
isProblemJson
|
|
@@ -189,14 +235,35 @@ const integrationCatalogEntrySchema = zod.z.object({
|
|
|
189
235
|
capabilities: zod.z.object({ mcp: zod.z.boolean().optional() })
|
|
190
236
|
});
|
|
191
237
|
const integrationCatalogResponseSchema = zod.z.object({ integrations: zod.z.array(integrationCatalogEntrySchema) });
|
|
192
|
-
|
|
193
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Secondary access token minted by the vendor alongside the primary oauth2
|
|
240
|
+
* credential (e.g. `devPortalAccessToken` on Microsoft Teams connections).
|
|
241
|
+
* Keyed by the vendor's connection-config field name. Treat this like any
|
|
242
|
+
* other bearer credential — it authenticates second-audience API calls
|
|
243
|
+
* (Teams Dev Portal, etc.) and must not be logged or forwarded to code that
|
|
244
|
+
* shouldn't hold connection secrets.
|
|
245
|
+
*/
|
|
246
|
+
const secondaryAccessTokenSchema = zod.z.object({
|
|
194
247
|
accessToken: zod.z.string(),
|
|
195
248
|
expiresAt: zod.z.string().nullable()
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
249
|
+
});
|
|
250
|
+
const credentialSchema = zod.z.discriminatedUnion("type", [
|
|
251
|
+
zod.z.object({
|
|
252
|
+
type: zod.z.literal("oauth2"),
|
|
253
|
+
accessToken: zod.z.string(),
|
|
254
|
+
expiresAt: zod.z.string().nullable(),
|
|
255
|
+
secondaryAccessTokens: zod.z.record(zod.z.string(), secondaryAccessTokenSchema).optional()
|
|
256
|
+
}),
|
|
257
|
+
zod.z.object({
|
|
258
|
+
type: zod.z.literal("api_key"),
|
|
259
|
+
apiKey: zod.z.string()
|
|
260
|
+
}),
|
|
261
|
+
zod.z.object({
|
|
262
|
+
type: zod.z.literal("two_step"),
|
|
263
|
+
token: zod.z.string(),
|
|
264
|
+
expiresAt: zod.z.string().nullable()
|
|
265
|
+
})
|
|
266
|
+
]);
|
|
200
267
|
const connectionContextSchema = zod.z.object({
|
|
201
268
|
connection_config: zod.z.record(zod.z.string(), zod.z.unknown()).nullable(),
|
|
202
269
|
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).nullable()
|
|
@@ -287,7 +354,12 @@ async function proxyRequestWithResponse(client, connectionId, options) {
|
|
|
287
354
|
}
|
|
288
355
|
const queryString = search.size > 0 ? `?${search.toString()}` : "";
|
|
289
356
|
const url = `/v2/connections/${encodeURIComponent(connectionId)}/proxy/${cleanPath}${queryString}`;
|
|
290
|
-
const headers = {
|
|
357
|
+
const headers = {};
|
|
358
|
+
for (const [name, value] of Object.entries(options.headers ?? {})) {
|
|
359
|
+
const lower = name.toLowerCase();
|
|
360
|
+
if (lower === "authorization" || lower === "proxy-authorization") continue;
|
|
361
|
+
headers[name] = value;
|
|
362
|
+
}
|
|
291
363
|
if (options.baseUrlOverride !== void 0) {
|
|
292
364
|
assertValidBaseUrlOverride(options.baseUrlOverride);
|
|
293
365
|
headers["base-url-override"] = options.baseUrlOverride;
|
|
@@ -637,8 +709,8 @@ function buildProxyMultiConnectionTools(input) {
|
|
|
637
709
|
* client cache so stale clients can be reaped elsewhere.
|
|
638
710
|
*/
|
|
639
711
|
async function buildMcpMultiConnectionTools(input) {
|
|
640
|
-
const { registration, connections, allowTools, disallowTools,
|
|
641
|
-
const
|
|
712
|
+
const { registration, connections, allowTools, disallowTools, requireApproval, client, mcpClients, resolverId } = input;
|
|
713
|
+
const requireApprovalFor = Array.isArray(requireApproval) ? new Set(requireApproval) : void 0;
|
|
642
714
|
const listToolKey = listConnectionsToolKey(registration.integrationId);
|
|
643
715
|
const innerAllowTools = allowTools?.filter((name) => name !== listToolKey);
|
|
644
716
|
const innerDisallowTools = disallowTools?.filter((name) => name !== listToolKey);
|
|
@@ -662,7 +734,7 @@ async function buildMcpMultiConnectionTools(input) {
|
|
|
662
734
|
id: `mastra-connect-${resolverId}-${registration.integrationId}-${connection.id}`,
|
|
663
735
|
servers: { [registration.integrationId]: {
|
|
664
736
|
...transport,
|
|
665
|
-
requireToolApproval: ({ toolName }) =>
|
|
737
|
+
...requireApproval === true ? { requireToolApproval: true } : requireApprovalFor ? { requireToolApproval: ({ toolName }) => requireApprovalFor.has(`${registration.integrationId}_${String(toolName)}`) } : {}
|
|
666
738
|
} }
|
|
667
739
|
})
|
|
668
740
|
};
|
|
@@ -679,8 +751,10 @@ async function buildMcpMultiConnectionTools(input) {
|
|
|
679
751
|
}
|
|
680
752
|
const catalogUnion = /* @__PURE__ */ new Set();
|
|
681
753
|
for (const catalog of rawInnerCatalogs.values()) for (const key of Object.keys(catalog)) catalogUnion.add(key);
|
|
682
|
-
|
|
683
|
-
|
|
754
|
+
if (requireApprovalFor) {
|
|
755
|
+
const unknown = [...requireApprovalFor].filter((name) => !catalogUnion.has(name));
|
|
756
|
+
if (unknown.length > 0) throw new MastraConnectConfigError(`Unknown tool name(s) in requireApproval for '${registration.integrationId}': ${unknown.join(", ")}. Known tools: ${[...catalogUnion].join(", ")}.`);
|
|
757
|
+
}
|
|
684
758
|
innerToolsByConnectionId = /* @__PURE__ */ new Map();
|
|
685
759
|
for (const [connectionId, catalog] of rawInnerCatalogs) {
|
|
686
760
|
const filtered = applyToolFilter(catalog, {
|
|
@@ -709,10 +783,14 @@ async function buildMcpMultiConnectionTools(input) {
|
|
|
709
783
|
//#endregion
|
|
710
784
|
//#region src/providers/channels.ts
|
|
711
785
|
function credentialToken$1(credential) {
|
|
712
|
-
|
|
786
|
+
switch (credential.type) {
|
|
787
|
+
case "oauth2": return credential.accessToken;
|
|
788
|
+
case "two_step": return credential.token;
|
|
789
|
+
default: return credential.apiKey;
|
|
790
|
+
}
|
|
713
791
|
}
|
|
714
792
|
const RESERVED_OPTION_KEYS = {
|
|
715
|
-
slack: [
|
|
793
|
+
"slack-channels": [
|
|
716
794
|
"baseUrl",
|
|
717
795
|
"refreshToken",
|
|
718
796
|
"token",
|
|
@@ -726,7 +804,14 @@ const RESERVED_OPTION_KEYS = {
|
|
|
726
804
|
"tokenResolver",
|
|
727
805
|
"encryptionKey"
|
|
728
806
|
],
|
|
729
|
-
discord: ["baseUrl", "encryptionKey"]
|
|
807
|
+
discord: ["baseUrl", "encryptionKey"],
|
|
808
|
+
"microsoft-teams": [
|
|
809
|
+
"baseUrl",
|
|
810
|
+
"appId",
|
|
811
|
+
"appPassword",
|
|
812
|
+
"tokenResolver",
|
|
813
|
+
"encryptionKey"
|
|
814
|
+
]
|
|
730
815
|
};
|
|
731
816
|
function stripReservedOptions(integrationId, options) {
|
|
732
817
|
if (!options) return options;
|
|
@@ -746,10 +831,10 @@ function stripReservedOptions(integrationId, options) {
|
|
|
746
831
|
}
|
|
747
832
|
const CHANNELS$1 = [
|
|
748
833
|
{
|
|
749
|
-
integrationId: "slack",
|
|
834
|
+
integrationId: "slack-channels",
|
|
750
835
|
async create(options, runtime) {
|
|
751
836
|
const mod = await import("@mastra/slack");
|
|
752
|
-
const safeOptions = stripReservedOptions("slack", options);
|
|
837
|
+
const safeOptions = stripReservedOptions("slack-channels", options);
|
|
753
838
|
const tokenResolver = async () => {
|
|
754
839
|
return credentialToken$1(await runtime.getCredential());
|
|
755
840
|
};
|
|
@@ -783,9 +868,11 @@ const CHANNELS$1 = [
|
|
|
783
868
|
return {
|
|
784
869
|
provider,
|
|
785
870
|
async sync() {
|
|
871
|
+
const credential = await runtime.getCredential();
|
|
872
|
+
if (credential.type !== "api_key") throw new MastraConnectError("unsupported_credential_type", `Discord connection ${runtime.getConnectionId()} returned a '${credential.type}' credential, but the Discord channel requires the bot token as an API-key credential (the 'discord' integration). OAuth Discord connections yield user Bearer tokens, which Discord rejects for bot auth.`);
|
|
873
|
+
const botToken = credential.apiKey;
|
|
874
|
+
if (typeof botToken !== "string" || botToken.length === 0) throw new MastraConnectError("no_active_connection", `Discord connection ${runtime.getConnectionId()} has no bot token on its credential.`);
|
|
786
875
|
const metadata = (await runtime.getConnectionContext())?.metadata ?? {};
|
|
787
|
-
const botToken = typeof metadata.botToken === "string" && metadata.botToken || typeof metadata.bot_token === "string" && metadata.bot_token || void 0;
|
|
788
|
-
if (!botToken) throw new MastraConnectError("no_active_connection", `Discord connection ${runtime.getConnectionId()} has no botToken in its metadata. Store the bot token on the connection (Nango setMetadata) to activate the Discord channel.`);
|
|
789
876
|
const applicationId = optionsAppId ?? (typeof metadata.applicationId === "string" ? metadata.applicationId : void 0) ?? (typeof metadata.application_id === "string" ? metadata.application_id : void 0);
|
|
790
877
|
const publicKey = optionsPublicKey ?? (typeof metadata.publicKey === "string" ? metadata.publicKey : void 0) ?? (typeof metadata.public_key === "string" ? metadata.public_key : void 0);
|
|
791
878
|
const credentials = { botToken };
|
|
@@ -795,17 +882,42 @@ const CHANNELS$1 = [
|
|
|
795
882
|
}
|
|
796
883
|
};
|
|
797
884
|
}
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
integrationId: "microsoft-teams",
|
|
888
|
+
async create(options, runtime) {
|
|
889
|
+
const mod = await import("@mastra/teams");
|
|
890
|
+
if (!process.env.MASTRA_ENCRYPTION_KEY) throw new MastraConnectError("invalid_options", "Microsoft Teams channel: MASTRA_ENCRYPTION_KEY is not set. The Teams install store persists per-agent bot secrets and requires an at-rest encryption key (a 32-byte value, base64-encoded).");
|
|
891
|
+
const safeOptions = stripReservedOptions("microsoft-teams", options);
|
|
892
|
+
const tokenResolver = async (scope) => {
|
|
893
|
+
const fresh = await runtime.getCredential();
|
|
894
|
+
if (!(Array.isArray(scope) ? scope : [scope]).includes(mod.TEAMS_DEV_PORTAL_SCOPE)) return credentialToken$1(fresh);
|
|
895
|
+
const token = fresh.type === "oauth2" ? fresh.secondaryAccessTokens?.devPortalAccessToken?.accessToken : void 0;
|
|
896
|
+
if (!token) throw new MastraConnectError("no_active_connection", `Teams connection ${runtime.getConnectionId()} has no Dev Portal token on its credential. Reconnect with an integration that requests the ${mod.TEAMS_DEV_PORTAL_SCOPE} scope.`);
|
|
897
|
+
return token;
|
|
898
|
+
};
|
|
899
|
+
return { provider: new mod.TeamsProvider({
|
|
900
|
+
tokenResolver,
|
|
901
|
+
...safeOptions ?? {}
|
|
902
|
+
}) };
|
|
903
|
+
}
|
|
798
904
|
}
|
|
799
905
|
];
|
|
800
906
|
//#endregion
|
|
801
907
|
//#region src/runtime/platform-proxy.ts
|
|
802
908
|
/** Maps the platform credential to the field names templates are written against. */
|
|
803
909
|
function toTemplateCredentials(credential) {
|
|
804
|
-
|
|
910
|
+
if (credential.type === "oauth2") return {
|
|
805
911
|
type: "OAUTH2",
|
|
806
912
|
access_token: credential.accessToken,
|
|
807
913
|
expires_at: credential.expiresAt
|
|
808
|
-
}
|
|
914
|
+
};
|
|
915
|
+
if (credential.type === "two_step") return {
|
|
916
|
+
type: "TWO_STEP",
|
|
917
|
+
token: credential.token,
|
|
918
|
+
expires_at: credential.expiresAt
|
|
919
|
+
};
|
|
920
|
+
return {
|
|
809
921
|
type: "API_KEY",
|
|
810
922
|
apiKey: credential.apiKey
|
|
811
923
|
};
|
|
@@ -1733,8 +1845,8 @@ const anthropicProvider = {
|
|
|
1733
1845
|
//#endregion
|
|
1734
1846
|
//#region src/providers/clerk/tools/assign-organization-role-permission.ts
|
|
1735
1847
|
const assignOrganizationRolePermissionInputSchema = zod.z.object({
|
|
1736
|
-
organization_role_id: zod.z.string(),
|
|
1737
|
-
permission_id: zod.z.string()
|
|
1848
|
+
organization_role_id: zod.z.string().min(1),
|
|
1849
|
+
permission_id: zod.z.string().min(1)
|
|
1738
1850
|
});
|
|
1739
1851
|
const ResourceSchema$49 = zod.z.object({
|
|
1740
1852
|
id: zod.z.string(),
|
|
@@ -1770,8 +1882,8 @@ function assignOrganizationRolePermissionTool(proxy) {
|
|
|
1770
1882
|
//#endregion
|
|
1771
1883
|
//#region src/providers/clerk/tools/create-email-address.ts
|
|
1772
1884
|
const createEmailAddressInputSchema = zod.z.object({
|
|
1773
|
-
user_id: zod.z.string(),
|
|
1774
|
-
email_address: zod.z.string(),
|
|
1885
|
+
user_id: zod.z.string().min(1),
|
|
1886
|
+
email_address: zod.z.string().email(),
|
|
1775
1887
|
verified: zod.z.boolean().optional(),
|
|
1776
1888
|
primary: zod.z.boolean().optional(),
|
|
1777
1889
|
notify_primary_email_address_changed: zod.z.boolean().optional()
|
|
@@ -1816,16 +1928,22 @@ function createEmailAddressTool(proxy) {
|
|
|
1816
1928
|
}
|
|
1817
1929
|
//#endregion
|
|
1818
1930
|
//#region src/providers/clerk/tools/create-organization-domain.ts
|
|
1819
|
-
const EnrollmentModeSchema$
|
|
1931
|
+
const EnrollmentModeSchema$3 = zod.z.enum([
|
|
1820
1932
|
"manual_invitation",
|
|
1821
1933
|
"automatic_invitation",
|
|
1822
1934
|
"automatic_suggestion",
|
|
1823
1935
|
"enterprise_sso"
|
|
1824
1936
|
]);
|
|
1937
|
+
const EnrollmentModeSchemaWidened$2 = zod.z.enum([
|
|
1938
|
+
"manual_invitation",
|
|
1939
|
+
"automatic_invitation",
|
|
1940
|
+
"automatic_suggestion",
|
|
1941
|
+
"enterprise_sso"
|
|
1942
|
+
]).or(zod.z.string());
|
|
1825
1943
|
const createOrganizationDomainInputSchema$1 = zod.z.object({
|
|
1826
|
-
organization_id: zod.z.string(),
|
|
1944
|
+
organization_id: zod.z.string().min(1),
|
|
1827
1945
|
name: zod.z.string(),
|
|
1828
|
-
enrollment_mode: EnrollmentModeSchema$
|
|
1946
|
+
enrollment_mode: EnrollmentModeSchema$3,
|
|
1829
1947
|
verified: zod.z.boolean().optional()
|
|
1830
1948
|
});
|
|
1831
1949
|
const ResourceSchema$47 = zod.z.object({
|
|
@@ -1833,15 +1951,15 @@ const ResourceSchema$47 = zod.z.object({
|
|
|
1833
1951
|
object: zod.z.string().optional(),
|
|
1834
1952
|
organization_id: zod.z.string().optional(),
|
|
1835
1953
|
name: zod.z.string(),
|
|
1836
|
-
enrollment_mode:
|
|
1954
|
+
enrollment_mode: EnrollmentModeSchemaWidened$2.optional(),
|
|
1837
1955
|
affiliation_verification: zod.z.object({
|
|
1838
1956
|
attempts: zod.z.number().optional(),
|
|
1839
1957
|
status: zod.z.string().optional()
|
|
1840
|
-
}).passthrough().optional(),
|
|
1958
|
+
}).passthrough().nullable().optional(),
|
|
1841
1959
|
verification: zod.z.object({
|
|
1842
1960
|
attempts: zod.z.number().optional(),
|
|
1843
1961
|
status: zod.z.string().optional()
|
|
1844
|
-
}).passthrough().optional(),
|
|
1962
|
+
}).passthrough().nullable().optional(),
|
|
1845
1963
|
verified: zod.z.boolean().optional(),
|
|
1846
1964
|
created_at: zod.z.number().optional(),
|
|
1847
1965
|
updated_at: zod.z.number().optional()
|
|
@@ -1870,7 +1988,7 @@ function createOrganizationDomainTool$1(proxy) {
|
|
|
1870
1988
|
//#endregion
|
|
1871
1989
|
//#region src/providers/clerk/tools/create-organization-invitation.ts
|
|
1872
1990
|
const createOrganizationInvitationInputSchema = zod.z.object({
|
|
1873
|
-
organization_id: zod.z.string(),
|
|
1991
|
+
organization_id: zod.z.string().min(1),
|
|
1874
1992
|
email_address: zod.z.string().email(),
|
|
1875
1993
|
role: zod.z.string(),
|
|
1876
1994
|
inviter_user_id: zod.z.string().optional(),
|
|
@@ -1891,7 +2009,7 @@ const ResourceSchema$46 = zod.z.object({
|
|
|
1891
2009
|
"accepted",
|
|
1892
2010
|
"revoked",
|
|
1893
2011
|
"expired"
|
|
1894
|
-
]).optional(),
|
|
2012
|
+
]).or(zod.z.string()).optional(),
|
|
1895
2013
|
created_at: zod.z.number().optional(),
|
|
1896
2014
|
updated_at: zod.z.number().optional()
|
|
1897
2015
|
}).passthrough();
|
|
@@ -1924,8 +2042,8 @@ function createOrganizationInvitationTool(proxy) {
|
|
|
1924
2042
|
//#endregion
|
|
1925
2043
|
//#region src/providers/clerk/tools/create-organization-membership.ts
|
|
1926
2044
|
const createOrganizationMembershipInputSchema$1 = zod.z.object({
|
|
1927
|
-
organization_id: zod.z.string(),
|
|
1928
|
-
user_id: zod.z.string(),
|
|
2045
|
+
organization_id: zod.z.string().min(1),
|
|
2046
|
+
user_id: zod.z.string().min(1),
|
|
1929
2047
|
role: zod.z.string(),
|
|
1930
2048
|
public_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
1931
2049
|
private_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
@@ -2061,7 +2179,7 @@ function createOrganizationTool$1(proxy) {
|
|
|
2061
2179
|
//#endregion
|
|
2062
2180
|
//#region src/providers/clerk/tools/create-phone-number.ts
|
|
2063
2181
|
const createPhoneNumberInputSchema = zod.z.object({
|
|
2064
|
-
user_id: zod.z.string(),
|
|
2182
|
+
user_id: zod.z.string().min(1),
|
|
2065
2183
|
phone_number: zod.z.string(),
|
|
2066
2184
|
verified: zod.z.boolean().optional(),
|
|
2067
2185
|
primary: zod.z.boolean().optional(),
|
|
@@ -2124,7 +2242,7 @@ const createUserInputSchema$2 = zod.z.object({
|
|
|
2124
2242
|
public_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
2125
2243
|
private_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
2126
2244
|
unsafe_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
2127
|
-
});
|
|
2245
|
+
}).refine((value) => (value.email_address?.length ?? 0) > 0 || (value.phone_number?.length ?? 0) > 0 || value.username !== void 0 || value.password !== void 0, { message: "Provide at least one of email_address, phone_number, username, or password." });
|
|
2128
2246
|
const UserSchema$27 = zod.z.object({
|
|
2129
2247
|
id: zod.z.string(),
|
|
2130
2248
|
object: zod.z.string().optional(),
|
|
@@ -2176,7 +2294,7 @@ function createUserTool$2(proxy) {
|
|
|
2176
2294
|
}
|
|
2177
2295
|
//#endregion
|
|
2178
2296
|
//#region src/providers/clerk/tools/delete-email-address.ts
|
|
2179
|
-
const deleteEmailAddressInputSchema = zod.z.object({ email_address_id: zod.z.string() });
|
|
2297
|
+
const deleteEmailAddressInputSchema = zod.z.object({ email_address_id: zod.z.string().min(1) });
|
|
2180
2298
|
const deleteEmailAddressOutputSchema = zod.z.object({
|
|
2181
2299
|
id: zod.z.string(),
|
|
2182
2300
|
success: zod.z.boolean()
|
|
@@ -2202,8 +2320,8 @@ function deleteEmailAddressTool(proxy) {
|
|
|
2202
2320
|
//#endregion
|
|
2203
2321
|
//#region src/providers/clerk/tools/delete-organization-domain.ts
|
|
2204
2322
|
const deleteOrganizationDomainInputSchema$1 = zod.z.object({
|
|
2205
|
-
organization_id: zod.z.string(),
|
|
2206
|
-
domain_id: zod.z.string()
|
|
2323
|
+
organization_id: zod.z.string().min(1),
|
|
2324
|
+
domain_id: zod.z.string().min(1)
|
|
2207
2325
|
});
|
|
2208
2326
|
const deleteOrganizationDomainOutputSchema$1 = zod.z.object({
|
|
2209
2327
|
id: zod.z.string(),
|
|
@@ -2230,8 +2348,8 @@ function deleteOrganizationDomainTool$1(proxy) {
|
|
|
2230
2348
|
//#endregion
|
|
2231
2349
|
//#region src/providers/clerk/tools/delete-organization-membership.ts
|
|
2232
2350
|
const deleteOrganizationMembershipInputSchema$1 = zod.z.object({
|
|
2233
|
-
organization_id: zod.z.string(),
|
|
2234
|
-
user_id: zod.z.string()
|
|
2351
|
+
organization_id: zod.z.string().min(1),
|
|
2352
|
+
user_id: zod.z.string().min(1)
|
|
2235
2353
|
});
|
|
2236
2354
|
const deleteOrganizationMembershipOutputSchema$1 = zod.z.object({
|
|
2237
2355
|
id: zod.z.string(),
|
|
@@ -2257,7 +2375,7 @@ function deleteOrganizationMembershipTool$1(proxy) {
|
|
|
2257
2375
|
}
|
|
2258
2376
|
//#endregion
|
|
2259
2377
|
//#region src/providers/clerk/tools/delete-organization-role.ts
|
|
2260
|
-
const deleteOrganizationRoleInputSchema = zod.z.object({ organization_role_id: zod.z.string() });
|
|
2378
|
+
const deleteOrganizationRoleInputSchema = zod.z.object({ organization_role_id: zod.z.string().min(1) });
|
|
2261
2379
|
const deleteOrganizationRoleOutputSchema = zod.z.object({
|
|
2262
2380
|
id: zod.z.string(),
|
|
2263
2381
|
success: zod.z.boolean()
|
|
@@ -2307,7 +2425,7 @@ function deleteOrganizationTool$1(proxy) {
|
|
|
2307
2425
|
}
|
|
2308
2426
|
//#endregion
|
|
2309
2427
|
//#region src/providers/clerk/tools/delete-phone-number.ts
|
|
2310
|
-
const deletePhoneNumberInputSchema = zod.z.object({ phone_number_id: zod.z.string() });
|
|
2428
|
+
const deletePhoneNumberInputSchema = zod.z.object({ phone_number_id: zod.z.string().min(1) });
|
|
2311
2429
|
const deletePhoneNumberOutputSchema = zod.z.object({
|
|
2312
2430
|
id: zod.z.string(),
|
|
2313
2431
|
success: zod.z.boolean()
|
|
@@ -2357,7 +2475,7 @@ function deleteUserTool$2(proxy) {
|
|
|
2357
2475
|
}
|
|
2358
2476
|
//#endregion
|
|
2359
2477
|
//#region src/providers/clerk/tools/get-email-address.ts
|
|
2360
|
-
const getEmailAddressInputSchema = zod.z.object({ email_address_id: zod.z.string() });
|
|
2478
|
+
const getEmailAddressInputSchema = zod.z.object({ email_address_id: zod.z.string().min(1) });
|
|
2361
2479
|
const ResourceSchema$42 = zod.z.object({
|
|
2362
2480
|
id: zod.z.string(),
|
|
2363
2481
|
object: zod.z.string().optional(),
|
|
@@ -2392,8 +2510,8 @@ function getEmailAddressTool(proxy) {
|
|
|
2392
2510
|
//#endregion
|
|
2393
2511
|
//#region src/providers/clerk/tools/get-organization-invitation.ts
|
|
2394
2512
|
const getOrganizationInvitationInputSchema = zod.z.object({
|
|
2395
|
-
organization_id: zod.z.string(),
|
|
2396
|
-
invitation_id: zod.z.string()
|
|
2513
|
+
organization_id: zod.z.string().min(1),
|
|
2514
|
+
invitation_id: zod.z.string().min(1)
|
|
2397
2515
|
});
|
|
2398
2516
|
const ResourceSchema$41 = zod.z.object({
|
|
2399
2517
|
id: zod.z.string(),
|
|
@@ -2406,7 +2524,7 @@ const ResourceSchema$41 = zod.z.object({
|
|
|
2406
2524
|
"accepted",
|
|
2407
2525
|
"revoked",
|
|
2408
2526
|
"expired"
|
|
2409
|
-
]).optional(),
|
|
2527
|
+
]).or(zod.z.string()).optional(),
|
|
2410
2528
|
created_at: zod.z.number().optional(),
|
|
2411
2529
|
updated_at: zod.z.number().optional()
|
|
2412
2530
|
}).passthrough();
|
|
@@ -2428,7 +2546,7 @@ function getOrganizationInvitationTool(proxy) {
|
|
|
2428
2546
|
}
|
|
2429
2547
|
//#endregion
|
|
2430
2548
|
//#region src/providers/clerk/tools/get-organization-role.ts
|
|
2431
|
-
const getOrganizationRoleInputSchema = zod.z.object({ organization_role_id: zod.z.string() });
|
|
2549
|
+
const getOrganizationRoleInputSchema = zod.z.object({ organization_role_id: zod.z.string().min(1) });
|
|
2432
2550
|
const ResourceSchema$40 = zod.z.object({
|
|
2433
2551
|
id: zod.z.string(),
|
|
2434
2552
|
object: zod.z.string().optional(),
|
|
@@ -2500,7 +2618,7 @@ function getOrganizationTool$1(proxy) {
|
|
|
2500
2618
|
}
|
|
2501
2619
|
//#endregion
|
|
2502
2620
|
//#region src/providers/clerk/tools/get-phone-number.ts
|
|
2503
|
-
const getPhoneNumberInputSchema = zod.z.object({ phone_number_id: zod.z.string() });
|
|
2621
|
+
const getPhoneNumberInputSchema = zod.z.object({ phone_number_id: zod.z.string().min(1) });
|
|
2504
2622
|
const ResourceSchema$39 = zod.z.object({
|
|
2505
2623
|
id: zod.z.string(),
|
|
2506
2624
|
object: zod.z.string().optional(),
|
|
@@ -2535,7 +2653,7 @@ function getPhoneNumberTool(proxy) {
|
|
|
2535
2653
|
}
|
|
2536
2654
|
//#endregion
|
|
2537
2655
|
//#region src/providers/clerk/tools/get-session.ts
|
|
2538
|
-
const getSessionInputSchema = zod.z.object({ session_id: zod.z.string() });
|
|
2656
|
+
const getSessionInputSchema = zod.z.object({ session_id: zod.z.string().min(1) });
|
|
2539
2657
|
const ResourceSchema$38 = zod.z.object({
|
|
2540
2658
|
id: zod.z.string(),
|
|
2541
2659
|
object: zod.z.string().optional(),
|
|
@@ -2549,7 +2667,7 @@ const ResourceSchema$38 = zod.z.object({
|
|
|
2549
2667
|
"removed",
|
|
2550
2668
|
"replaced",
|
|
2551
2669
|
"revoked"
|
|
2552
|
-
]).optional(),
|
|
2670
|
+
]).or(zod.z.string()).optional(),
|
|
2553
2671
|
last_active_at: zod.z.number().optional(),
|
|
2554
2672
|
expire_at: zod.z.number().optional(),
|
|
2555
2673
|
abandon_at: zod.z.number().optional(),
|
|
@@ -2609,33 +2727,39 @@ function getUserTool$7(proxy) {
|
|
|
2609
2727
|
}
|
|
2610
2728
|
//#endregion
|
|
2611
2729
|
//#region src/providers/clerk/tools/list-organization-domains.ts
|
|
2612
|
-
const EnrollmentModeSchema$
|
|
2730
|
+
const EnrollmentModeSchema$2 = zod.z.enum([
|
|
2613
2731
|
"manual_invitation",
|
|
2614
2732
|
"automatic_invitation",
|
|
2615
2733
|
"automatic_suggestion",
|
|
2616
2734
|
"enterprise_sso"
|
|
2617
2735
|
]);
|
|
2736
|
+
const EnrollmentModeSchemaWidened$1 = zod.z.enum([
|
|
2737
|
+
"manual_invitation",
|
|
2738
|
+
"automatic_invitation",
|
|
2739
|
+
"automatic_suggestion",
|
|
2740
|
+
"enterprise_sso"
|
|
2741
|
+
]).or(zod.z.string());
|
|
2618
2742
|
const listOrganizationDomainsInputSchema = zod.z.object({
|
|
2619
|
-
cursor: zod.z.string().optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2743
|
+
cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2620
2744
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2621
|
-
organization_id: zod.z.string(),
|
|
2745
|
+
organization_id: zod.z.string().min(1),
|
|
2622
2746
|
verified: zod.z.boolean().optional(),
|
|
2623
|
-
enrollment_mode: EnrollmentModeSchema$
|
|
2747
|
+
enrollment_mode: EnrollmentModeSchema$2.optional()
|
|
2624
2748
|
});
|
|
2625
2749
|
const ResourceSchema$37 = zod.z.object({
|
|
2626
2750
|
id: zod.z.string(),
|
|
2627
2751
|
object: zod.z.string().optional(),
|
|
2628
2752
|
organization_id: zod.z.string().optional(),
|
|
2629
2753
|
name: zod.z.string(),
|
|
2630
|
-
enrollment_mode:
|
|
2754
|
+
enrollment_mode: EnrollmentModeSchemaWidened$1.optional(),
|
|
2631
2755
|
affiliation_verification: zod.z.object({
|
|
2632
2756
|
attempts: zod.z.number().optional(),
|
|
2633
2757
|
status: zod.z.string().optional()
|
|
2634
|
-
}).passthrough().optional(),
|
|
2758
|
+
}).passthrough().nullable().optional(),
|
|
2635
2759
|
verification: zod.z.object({
|
|
2636
2760
|
attempts: zod.z.number().optional(),
|
|
2637
2761
|
status: zod.z.string().optional()
|
|
2638
|
-
}).passthrough().optional(),
|
|
2762
|
+
}).passthrough().nullable().optional(),
|
|
2639
2763
|
verified: zod.z.boolean().optional(),
|
|
2640
2764
|
created_at: zod.z.number().optional(),
|
|
2641
2765
|
updated_at: zod.z.number().optional()
|
|
@@ -2646,7 +2770,7 @@ const ProviderResponseSchema$244 = zod.z.object({
|
|
|
2646
2770
|
});
|
|
2647
2771
|
const listOrganizationDomainsOutputSchema = zod.z.object({
|
|
2648
2772
|
items: zod.z.array(ResourceSchema$37),
|
|
2649
|
-
next_cursor: zod.z.string().optional(),
|
|
2773
|
+
next_cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2650
2774
|
total: zod.z.number()
|
|
2651
2775
|
});
|
|
2652
2776
|
function listOrganizationDomainsTool(proxy) {
|
|
@@ -2657,11 +2781,7 @@ function listOrganizationDomainsTool(proxy) {
|
|
|
2657
2781
|
outputSchema: listOrganizationDomainsOutputSchema,
|
|
2658
2782
|
execute: async (input, { requestContext }) => {
|
|
2659
2783
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2660
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2661
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2662
|
-
type: "invalid_cursor",
|
|
2663
|
-
message: "Cursor must be a non-negative integer."
|
|
2664
|
-
});
|
|
2784
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2665
2785
|
const response = await platformProxy.get({
|
|
2666
2786
|
endpoint: `/v1/organizations/${encodeURIComponent(input.organization_id)}/domains`,
|
|
2667
2787
|
params: {
|
|
@@ -2685,9 +2805,9 @@ function listOrganizationDomainsTool(proxy) {
|
|
|
2685
2805
|
//#endregion
|
|
2686
2806
|
//#region src/providers/clerk/tools/list-organization-invitations.ts
|
|
2687
2807
|
const listOrganizationInvitationsInputSchema = zod.z.object({
|
|
2688
|
-
cursor: zod.z.string().optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2808
|
+
cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2689
2809
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2690
|
-
organization_id: zod.z.string(),
|
|
2810
|
+
organization_id: zod.z.string().min(1),
|
|
2691
2811
|
status: zod.z.enum([
|
|
2692
2812
|
"pending",
|
|
2693
2813
|
"accepted",
|
|
@@ -2708,7 +2828,7 @@ const ResourceSchema$36 = zod.z.object({
|
|
|
2708
2828
|
"accepted",
|
|
2709
2829
|
"revoked",
|
|
2710
2830
|
"expired"
|
|
2711
|
-
]).optional(),
|
|
2831
|
+
]).or(zod.z.string()).optional(),
|
|
2712
2832
|
created_at: zod.z.number().optional(),
|
|
2713
2833
|
updated_at: zod.z.number().optional()
|
|
2714
2834
|
}).passthrough();
|
|
@@ -2718,7 +2838,7 @@ const ProviderResponseSchema$243 = zod.z.object({
|
|
|
2718
2838
|
});
|
|
2719
2839
|
const listOrganizationInvitationsOutputSchema = zod.z.object({
|
|
2720
2840
|
items: zod.z.array(ResourceSchema$36),
|
|
2721
|
-
next_cursor: zod.z.string().optional(),
|
|
2841
|
+
next_cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2722
2842
|
total: zod.z.number()
|
|
2723
2843
|
});
|
|
2724
2844
|
function listOrganizationInvitationsTool(proxy) {
|
|
@@ -2729,11 +2849,7 @@ function listOrganizationInvitationsTool(proxy) {
|
|
|
2729
2849
|
outputSchema: listOrganizationInvitationsOutputSchema,
|
|
2730
2850
|
execute: async (input, { requestContext }) => {
|
|
2731
2851
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2732
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2733
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2734
|
-
type: "invalid_cursor",
|
|
2735
|
-
message: "Cursor must be a non-negative integer."
|
|
2736
|
-
});
|
|
2852
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2737
2853
|
const response = await platformProxy.get({
|
|
2738
2854
|
endpoint: `/v1/organizations/${encodeURIComponent(input.organization_id)}/invitations`,
|
|
2739
2855
|
params: {
|
|
@@ -2758,9 +2874,9 @@ function listOrganizationInvitationsTool(proxy) {
|
|
|
2758
2874
|
//#endregion
|
|
2759
2875
|
//#region src/providers/clerk/tools/list-organization-memberships.ts
|
|
2760
2876
|
const listOrganizationMembershipsInputSchema$1 = zod.z.object({
|
|
2761
|
-
cursor: zod.z.string().optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2877
|
+
cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2762
2878
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2763
|
-
organization_id: zod.z.string(),
|
|
2879
|
+
organization_id: zod.z.string().min(1),
|
|
2764
2880
|
user_id: zod.z.array(zod.z.string()).optional(),
|
|
2765
2881
|
email_address: zod.z.array(zod.z.string()).optional(),
|
|
2766
2882
|
phone_number: zod.z.array(zod.z.string()).optional(),
|
|
@@ -2794,7 +2910,7 @@ const ProviderResponseSchema$242 = zod.z.object({
|
|
|
2794
2910
|
});
|
|
2795
2911
|
const listOrganizationMembershipsOutputSchema$1 = zod.z.object({
|
|
2796
2912
|
items: zod.z.array(ResourceSchema$35),
|
|
2797
|
-
next_cursor: zod.z.string().optional(),
|
|
2913
|
+
next_cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2798
2914
|
total: zod.z.number()
|
|
2799
2915
|
});
|
|
2800
2916
|
function listOrganizationMembershipsTool$1(proxy) {
|
|
@@ -2805,11 +2921,7 @@ function listOrganizationMembershipsTool$1(proxy) {
|
|
|
2805
2921
|
outputSchema: listOrganizationMembershipsOutputSchema$1,
|
|
2806
2922
|
execute: async (input, { requestContext }) => {
|
|
2807
2923
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2808
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2809
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2810
|
-
type: "invalid_cursor",
|
|
2811
|
-
message: "Cursor must be a non-negative integer."
|
|
2812
|
-
});
|
|
2924
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2813
2925
|
const response = await platformProxy.get({
|
|
2814
2926
|
endpoint: `/v1/organizations/${encodeURIComponent(input.organization_id)}/memberships`,
|
|
2815
2927
|
params: {
|
|
@@ -2847,7 +2959,7 @@ function listOrganizationMembershipsTool$1(proxy) {
|
|
|
2847
2959
|
//#endregion
|
|
2848
2960
|
//#region src/providers/clerk/tools/list-organization-roles.ts
|
|
2849
2961
|
const listOrganizationRolesInputSchema = zod.z.object({
|
|
2850
|
-
cursor: zod.z.string().optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2962
|
+
cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2851
2963
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2852
2964
|
query: zod.z.string().optional(),
|
|
2853
2965
|
order_by: zod.z.string().optional()
|
|
@@ -2872,7 +2984,7 @@ const ProviderResponseSchema$241 = zod.z.object({
|
|
|
2872
2984
|
});
|
|
2873
2985
|
const listOrganizationRolesOutputSchema = zod.z.object({
|
|
2874
2986
|
items: zod.z.array(ResourceSchema$34),
|
|
2875
|
-
next_cursor: zod.z.string().optional(),
|
|
2987
|
+
next_cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2876
2988
|
total: zod.z.number()
|
|
2877
2989
|
});
|
|
2878
2990
|
function listOrganizationRolesTool(proxy) {
|
|
@@ -2883,11 +2995,7 @@ function listOrganizationRolesTool(proxy) {
|
|
|
2883
2995
|
outputSchema: listOrganizationRolesOutputSchema,
|
|
2884
2996
|
execute: async (input, { requestContext }) => {
|
|
2885
2997
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2886
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2887
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2888
|
-
type: "invalid_cursor",
|
|
2889
|
-
message: "Cursor must be a non-negative integer."
|
|
2890
|
-
});
|
|
2998
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2891
2999
|
const response = await platformProxy.get({
|
|
2892
3000
|
endpoint: "/v1/organization_roles",
|
|
2893
3001
|
params: {
|
|
@@ -2911,7 +3019,7 @@ function listOrganizationRolesTool(proxy) {
|
|
|
2911
3019
|
//#endregion
|
|
2912
3020
|
//#region src/providers/clerk/tools/list-organizations.ts
|
|
2913
3021
|
const listOrganizationsInputSchema$1 = zod.z.object({
|
|
2914
|
-
cursor: zod.z.string().optional(),
|
|
3022
|
+
cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2915
3023
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2916
3024
|
query: zod.z.string().optional(),
|
|
2917
3025
|
order_by: zod.z.string().optional().describe("Sort by name, created_at, or members_count, prefixed with + or -."),
|
|
@@ -2951,11 +3059,7 @@ function listOrganizationsTool$1(proxy) {
|
|
|
2951
3059
|
outputSchema: listOrganizationsOutputSchema$1,
|
|
2952
3060
|
execute: async (input, { requestContext }) => {
|
|
2953
3061
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2954
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2955
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2956
|
-
type: "invalid_cursor",
|
|
2957
|
-
message: "Cursor must be a non-negative integer."
|
|
2958
|
-
});
|
|
3062
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2959
3063
|
const response = await platformProxy.get({
|
|
2960
3064
|
endpoint: "/v1/organizations",
|
|
2961
3065
|
params: {
|
|
@@ -2981,10 +3085,10 @@ function listOrganizationsTool$1(proxy) {
|
|
|
2981
3085
|
//#endregion
|
|
2982
3086
|
//#region src/providers/clerk/tools/list-sessions.ts
|
|
2983
3087
|
const listSessionsInputSchema = zod.z.object({
|
|
2984
|
-
cursor: zod.z.string().optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
3088
|
+
cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
2985
3089
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2986
|
-
client_id: zod.z.string().optional(),
|
|
2987
|
-
user_id: zod.z.string().optional(),
|
|
3090
|
+
client_id: zod.z.string().min(1).optional(),
|
|
3091
|
+
user_id: zod.z.string().min(1).optional(),
|
|
2988
3092
|
status: zod.z.enum([
|
|
2989
3093
|
"abandoned",
|
|
2990
3094
|
"active",
|
|
@@ -2994,7 +3098,7 @@ const listSessionsInputSchema = zod.z.object({
|
|
|
2994
3098
|
"replaced",
|
|
2995
3099
|
"revoked"
|
|
2996
3100
|
]).optional()
|
|
2997
|
-
});
|
|
3101
|
+
}).refine((value) => value.client_id !== void 0 || value.user_id !== void 0, { message: "Provide at least one of client_id or user_id." });
|
|
2998
3102
|
const ResourceSchema$33 = zod.z.object({
|
|
2999
3103
|
id: zod.z.string(),
|
|
3000
3104
|
object: zod.z.string().optional(),
|
|
@@ -3008,21 +3112,17 @@ const ResourceSchema$33 = zod.z.object({
|
|
|
3008
3112
|
"removed",
|
|
3009
3113
|
"replaced",
|
|
3010
3114
|
"revoked"
|
|
3011
|
-
]).optional(),
|
|
3115
|
+
]).or(zod.z.string()).optional(),
|
|
3012
3116
|
last_active_at: zod.z.number().optional(),
|
|
3013
3117
|
expire_at: zod.z.number().optional(),
|
|
3014
3118
|
abandon_at: zod.z.number().optional(),
|
|
3015
3119
|
created_at: zod.z.number().optional(),
|
|
3016
3120
|
updated_at: zod.z.number().optional()
|
|
3017
3121
|
}).passthrough();
|
|
3018
|
-
const ProviderResponseSchema$239 = zod.z.
|
|
3019
|
-
data: zod.z.array(ResourceSchema$33),
|
|
3020
|
-
total_count: zod.z.number()
|
|
3021
|
-
});
|
|
3122
|
+
const ProviderResponseSchema$239 = zod.z.array(ResourceSchema$33);
|
|
3022
3123
|
const listSessionsOutputSchema = zod.z.object({
|
|
3023
3124
|
items: zod.z.array(ResourceSchema$33),
|
|
3024
|
-
next_cursor: zod.z.string().optional()
|
|
3025
|
-
total: zod.z.number()
|
|
3125
|
+
next_cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page.")
|
|
3026
3126
|
});
|
|
3027
3127
|
function listSessionsTool(proxy) {
|
|
3028
3128
|
return (0, _mastra_core_tools.createTool)({
|
|
@@ -3032,28 +3132,23 @@ function listSessionsTool(proxy) {
|
|
|
3032
3132
|
outputSchema: listSessionsOutputSchema,
|
|
3033
3133
|
execute: async (input, { requestContext }) => {
|
|
3034
3134
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
3035
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
3036
|
-
|
|
3037
|
-
type: "invalid_cursor",
|
|
3038
|
-
message: "Cursor must be a non-negative integer."
|
|
3039
|
-
});
|
|
3135
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
3136
|
+
const limit = input.limit ?? 10;
|
|
3040
3137
|
const response = await platformProxy.get({
|
|
3041
3138
|
endpoint: "/v1/sessions",
|
|
3042
3139
|
params: {
|
|
3043
3140
|
offset: String(offset),
|
|
3044
|
-
|
|
3141
|
+
limit: String(limit),
|
|
3045
3142
|
...input.client_id !== void 0 && { client_id: input.client_id },
|
|
3046
3143
|
...input.user_id !== void 0 && { user_id: input.user_id },
|
|
3047
3144
|
...input.status !== void 0 && { status: input.status }
|
|
3048
3145
|
},
|
|
3049
3146
|
retries: 3
|
|
3050
3147
|
});
|
|
3051
|
-
const
|
|
3052
|
-
const nextOffset = offset + provider.data.length;
|
|
3148
|
+
const sessions = ProviderResponseSchema$239.parse(response.data);
|
|
3053
3149
|
return {
|
|
3054
|
-
items:
|
|
3055
|
-
...
|
|
3056
|
-
total: provider.total_count
|
|
3150
|
+
items: sessions,
|
|
3151
|
+
...sessions.length === limit && { next_cursor: String(offset + sessions.length) }
|
|
3057
3152
|
};
|
|
3058
3153
|
}
|
|
3059
3154
|
});
|
|
@@ -3061,13 +3156,19 @@ function listSessionsTool(proxy) {
|
|
|
3061
3156
|
//#endregion
|
|
3062
3157
|
//#region src/providers/clerk/tools/list-users.ts
|
|
3063
3158
|
const listUsersInputSchema$9 = zod.z.object({
|
|
3064
|
-
cursor: zod.z.string().optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
3159
|
+
cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
3065
3160
|
limit: zod.z.number().int().min(1).max(500).optional().describe("Maximum number of users to return. Maximum 500."),
|
|
3066
3161
|
query: zod.z.string().optional().describe("Search across names, identifiers, email addresses, phone numbers, and usernames."),
|
|
3067
3162
|
email_address: zod.z.array(zod.z.string()).max(100).optional().describe("Filter by email addresses."),
|
|
3163
|
+
phone_number: zod.z.array(zod.z.string()).max(100).optional().describe("Filter by phone numbers."),
|
|
3164
|
+
username: zod.z.array(zod.z.string()).max(100).optional().describe("Filter by usernames."),
|
|
3068
3165
|
user_id: zod.z.array(zod.z.string()).max(100).optional().describe("Filter by Clerk user IDs."),
|
|
3069
3166
|
external_id: zod.z.array(zod.z.string()).max(100).optional().describe("Filter by external user IDs."),
|
|
3070
3167
|
organization_id: zod.z.array(zod.z.string()).max(100).optional().describe("Filter by organization IDs."),
|
|
3168
|
+
last_active_at_before: zod.z.number().int().optional().describe("Filter users last active before this Unix timestamp in milliseconds."),
|
|
3169
|
+
last_active_at_after: zod.z.number().int().optional().describe("Filter users last active after this Unix timestamp in milliseconds."),
|
|
3170
|
+
created_at_before: zod.z.number().int().optional().describe("Filter users created before this Unix timestamp in milliseconds."),
|
|
3171
|
+
created_at_after: zod.z.number().int().optional().describe("Filter users created after this Unix timestamp in milliseconds."),
|
|
3071
3172
|
order_by: zod.z.string().optional().describe("Sort field prefixed with + for ascending or - for descending. Example: \"-created_at\"")
|
|
3072
3173
|
});
|
|
3073
3174
|
const UserSchema$25 = zod.z.object({
|
|
@@ -3086,13 +3187,11 @@ const UserSchema$25 = zod.z.object({
|
|
|
3086
3187
|
updated_at: zod.z.number().optional(),
|
|
3087
3188
|
locale: zod.z.string().nullable().optional()
|
|
3088
3189
|
}).passthrough();
|
|
3089
|
-
const ProviderResponseSchema$238 = zod.z.
|
|
3090
|
-
|
|
3091
|
-
total_count: zod.z.number()
|
|
3092
|
-
});
|
|
3190
|
+
const ProviderResponseSchema$238 = zod.z.array(UserSchema$25);
|
|
3191
|
+
const ProviderCountSchema = zod.z.object({ total_count: zod.z.number() }).passthrough();
|
|
3093
3192
|
const listUsersOutputSchema$9 = zod.z.object({
|
|
3094
3193
|
items: zod.z.array(UserSchema$25),
|
|
3095
|
-
next_cursor: zod.z.string().optional(),
|
|
3194
|
+
next_cursor: zod.z.string().regex(/^\d+$/, "Cursor must be a non-negative integer.").refine((value) => Number.isSafeInteger(Number(value)), "Cursor must be a non-negative integer.").optional().describe("Pagination cursor returned by a previous request. Omit for the first page."),
|
|
3096
3195
|
total: zod.z.number()
|
|
3097
3196
|
});
|
|
3098
3197
|
function listUsersTool$9(proxy) {
|
|
@@ -3103,31 +3202,42 @@ function listUsersTool$9(proxy) {
|
|
|
3103
3202
|
outputSchema: listUsersOutputSchema$9,
|
|
3104
3203
|
execute: async (input, { requestContext }) => {
|
|
3105
3204
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
3106
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3205
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
3206
|
+
const filterParams = {
|
|
3207
|
+
...input.query !== void 0 && { query: input.query },
|
|
3208
|
+
...input.email_address !== void 0 && { email_address: input.email_address },
|
|
3209
|
+
...input.phone_number !== void 0 && { phone_number: input.phone_number },
|
|
3210
|
+
...input.username !== void 0 && { username: input.username },
|
|
3211
|
+
...input.user_id !== void 0 && { user_id: input.user_id },
|
|
3212
|
+
...input.external_id !== void 0 && { external_id: input.external_id },
|
|
3213
|
+
...input.organization_id !== void 0 && { organization_id: input.organization_id },
|
|
3214
|
+
...input.last_active_at_before !== void 0 && { last_active_at_before: String(input.last_active_at_before) },
|
|
3215
|
+
...input.last_active_at_after !== void 0 && { last_active_at_after: String(input.last_active_at_after) },
|
|
3216
|
+
...input.created_at_before !== void 0 && { created_at_before: String(input.created_at_before) },
|
|
3217
|
+
...input.created_at_after !== void 0 && { created_at_after: String(input.created_at_after) }
|
|
3218
|
+
};
|
|
3111
3219
|
const response = await platformProxy.get({
|
|
3112
3220
|
endpoint: "/v1/users",
|
|
3113
3221
|
params: {
|
|
3114
3222
|
offset: String(offset),
|
|
3115
3223
|
...input.limit !== void 0 && { limit: String(input.limit) },
|
|
3116
|
-
...input.
|
|
3117
|
-
...
|
|
3118
|
-
...input.user_id !== void 0 && { user_id: input.user_id },
|
|
3119
|
-
...input.external_id !== void 0 && { external_id: input.external_id },
|
|
3120
|
-
...input.organization_id !== void 0 && { organization_id: input.organization_id },
|
|
3121
|
-
...input.order_by !== void 0 && { order_by: input.order_by }
|
|
3224
|
+
...input.order_by !== void 0 && { order_by: input.order_by },
|
|
3225
|
+
...filterParams
|
|
3122
3226
|
},
|
|
3123
3227
|
retries: 3
|
|
3124
3228
|
});
|
|
3125
|
-
const
|
|
3126
|
-
const
|
|
3229
|
+
const users = ProviderResponseSchema$238.parse(response.data);
|
|
3230
|
+
const countResponse = await platformProxy.get({
|
|
3231
|
+
endpoint: "/v1/users/count",
|
|
3232
|
+
params: filterParams,
|
|
3233
|
+
retries: 3
|
|
3234
|
+
});
|
|
3235
|
+
const total = ProviderCountSchema.parse(countResponse.data).total_count;
|
|
3236
|
+
const nextOffset = offset + users.length;
|
|
3127
3237
|
return {
|
|
3128
|
-
items:
|
|
3129
|
-
...nextOffset <
|
|
3130
|
-
total
|
|
3238
|
+
items: users,
|
|
3239
|
+
...users.length > 0 && nextOffset < total && { next_cursor: String(nextOffset) },
|
|
3240
|
+
total
|
|
3131
3241
|
};
|
|
3132
3242
|
}
|
|
3133
3243
|
});
|
|
@@ -3135,8 +3245,8 @@ function listUsersTool$9(proxy) {
|
|
|
3135
3245
|
//#endregion
|
|
3136
3246
|
//#region src/providers/clerk/tools/remove-organization-role-permission.ts
|
|
3137
3247
|
const removeOrganizationRolePermissionInputSchema = zod.z.object({
|
|
3138
|
-
organization_role_id: zod.z.string(),
|
|
3139
|
-
permission_id: zod.z.string()
|
|
3248
|
+
organization_role_id: zod.z.string().min(1),
|
|
3249
|
+
permission_id: zod.z.string().min(1)
|
|
3140
3250
|
});
|
|
3141
3251
|
const removeOrganizationRolePermissionOutputSchema = zod.z.object({
|
|
3142
3252
|
id: zod.z.string(),
|
|
@@ -3163,8 +3273,8 @@ function removeOrganizationRolePermissionTool(proxy) {
|
|
|
3163
3273
|
//#endregion
|
|
3164
3274
|
//#region src/providers/clerk/tools/revoke-organization-invitation.ts
|
|
3165
3275
|
const revokeOrganizationInvitationInputSchema = zod.z.object({
|
|
3166
|
-
organization_id: zod.z.string(),
|
|
3167
|
-
invitation_id: zod.z.string(),
|
|
3276
|
+
organization_id: zod.z.string().min(1),
|
|
3277
|
+
invitation_id: zod.z.string().min(1),
|
|
3168
3278
|
requesting_user_id: zod.z.string().optional()
|
|
3169
3279
|
});
|
|
3170
3280
|
const ResourceSchema$32 = zod.z.object({
|
|
@@ -3178,7 +3288,7 @@ const ResourceSchema$32 = zod.z.object({
|
|
|
3178
3288
|
"accepted",
|
|
3179
3289
|
"revoked",
|
|
3180
3290
|
"expired"
|
|
3181
|
-
]).optional(),
|
|
3291
|
+
]).or(zod.z.string()).optional(),
|
|
3182
3292
|
created_at: zod.z.number().optional(),
|
|
3183
3293
|
updated_at: zod.z.number().optional()
|
|
3184
3294
|
}).passthrough();
|
|
@@ -3201,7 +3311,7 @@ function revokeOrganizationInvitationTool(proxy) {
|
|
|
3201
3311
|
}
|
|
3202
3312
|
//#endregion
|
|
3203
3313
|
//#region src/providers/clerk/tools/revoke-session.ts
|
|
3204
|
-
const revokeSessionInputSchema = zod.z.object({ session_id: zod.z.string() });
|
|
3314
|
+
const revokeSessionInputSchema = zod.z.object({ session_id: zod.z.string().min(1) });
|
|
3205
3315
|
const ResourceSchema$31 = zod.z.object({
|
|
3206
3316
|
id: zod.z.string(),
|
|
3207
3317
|
object: zod.z.string().optional(),
|
|
@@ -3215,7 +3325,7 @@ const ResourceSchema$31 = zod.z.object({
|
|
|
3215
3325
|
"removed",
|
|
3216
3326
|
"replaced",
|
|
3217
3327
|
"revoked"
|
|
3218
|
-
]).optional(),
|
|
3328
|
+
]).or(zod.z.string()).optional(),
|
|
3219
3329
|
last_active_at: zod.z.number().optional(),
|
|
3220
3330
|
expire_at: zod.z.number().optional(),
|
|
3221
3331
|
abandon_at: zod.z.number().optional(),
|
|
@@ -3242,7 +3352,7 @@ function revokeSessionTool(proxy) {
|
|
|
3242
3352
|
//#endregion
|
|
3243
3353
|
//#region src/providers/clerk/tools/update-email-address.ts
|
|
3244
3354
|
const updateEmailAddressInputSchema = zod.z.object({
|
|
3245
|
-
email_address_id: zod.z.string(),
|
|
3355
|
+
email_address_id: zod.z.string().min(1),
|
|
3246
3356
|
verified: zod.z.boolean().optional(),
|
|
3247
3357
|
primary: zod.z.boolean().optional(),
|
|
3248
3358
|
notify_primary_email_address_changed: zod.z.boolean().optional()
|
|
@@ -3285,16 +3395,22 @@ function updateEmailAddressTool(proxy) {
|
|
|
3285
3395
|
}
|
|
3286
3396
|
//#endregion
|
|
3287
3397
|
//#region src/providers/clerk/tools/update-organization-domain.ts
|
|
3288
|
-
const EnrollmentModeSchema = zod.z.enum([
|
|
3398
|
+
const EnrollmentModeSchema$1 = zod.z.enum([
|
|
3289
3399
|
"manual_invitation",
|
|
3290
3400
|
"automatic_invitation",
|
|
3291
3401
|
"automatic_suggestion",
|
|
3292
3402
|
"enterprise_sso"
|
|
3293
3403
|
]);
|
|
3404
|
+
const EnrollmentModeSchemaWidened = zod.z.enum([
|
|
3405
|
+
"manual_invitation",
|
|
3406
|
+
"automatic_invitation",
|
|
3407
|
+
"automatic_suggestion",
|
|
3408
|
+
"enterprise_sso"
|
|
3409
|
+
]).or(zod.z.string());
|
|
3294
3410
|
const updateOrganizationDomainInputSchema = zod.z.object({
|
|
3295
|
-
organization_id: zod.z.string(),
|
|
3296
|
-
domain_id: zod.z.string(),
|
|
3297
|
-
enrollment_mode: EnrollmentModeSchema.optional(),
|
|
3411
|
+
organization_id: zod.z.string().min(1),
|
|
3412
|
+
domain_id: zod.z.string().min(1),
|
|
3413
|
+
enrollment_mode: EnrollmentModeSchema$1.optional(),
|
|
3298
3414
|
verified: zod.z.boolean().optional()
|
|
3299
3415
|
});
|
|
3300
3416
|
const ResourceSchema$29 = zod.z.object({
|
|
@@ -3302,15 +3418,15 @@ const ResourceSchema$29 = zod.z.object({
|
|
|
3302
3418
|
object: zod.z.string().optional(),
|
|
3303
3419
|
organization_id: zod.z.string().optional(),
|
|
3304
3420
|
name: zod.z.string(),
|
|
3305
|
-
enrollment_mode:
|
|
3421
|
+
enrollment_mode: EnrollmentModeSchemaWidened.optional(),
|
|
3306
3422
|
affiliation_verification: zod.z.object({
|
|
3307
3423
|
attempts: zod.z.number().optional(),
|
|
3308
3424
|
status: zod.z.string().optional()
|
|
3309
|
-
}).passthrough().optional(),
|
|
3425
|
+
}).passthrough().nullable().optional(),
|
|
3310
3426
|
verification: zod.z.object({
|
|
3311
3427
|
attempts: zod.z.number().optional(),
|
|
3312
3428
|
status: zod.z.string().optional()
|
|
3313
|
-
}).passthrough().optional(),
|
|
3429
|
+
}).passthrough().nullable().optional(),
|
|
3314
3430
|
verified: zod.z.boolean().optional(),
|
|
3315
3431
|
created_at: zod.z.number().optional(),
|
|
3316
3432
|
updated_at: zod.z.number().optional()
|
|
@@ -3338,8 +3454,8 @@ function updateOrganizationDomainTool(proxy) {
|
|
|
3338
3454
|
//#endregion
|
|
3339
3455
|
//#region src/providers/clerk/tools/update-organization-membership-metadata.ts
|
|
3340
3456
|
const updateOrganizationMembershipMetadataInputSchema = zod.z.object({
|
|
3341
|
-
organization_id: zod.z.string(),
|
|
3342
|
-
user_id: zod.z.string(),
|
|
3457
|
+
organization_id: zod.z.string().min(1),
|
|
3458
|
+
user_id: zod.z.string().min(1),
|
|
3343
3459
|
public_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3344
3460
|
private_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3345
3461
|
});
|
|
@@ -3376,8 +3492,8 @@ function updateOrganizationMembershipMetadataTool(proxy) {
|
|
|
3376
3492
|
//#endregion
|
|
3377
3493
|
//#region src/providers/clerk/tools/update-organization-membership.ts
|
|
3378
3494
|
const updateOrganizationMembershipInputSchema$1 = zod.z.object({
|
|
3379
|
-
organization_id: zod.z.string(),
|
|
3380
|
-
user_id: zod.z.string(),
|
|
3495
|
+
organization_id: zod.z.string().min(1),
|
|
3496
|
+
user_id: zod.z.string().min(1),
|
|
3381
3497
|
role: zod.z.string()
|
|
3382
3498
|
});
|
|
3383
3499
|
const ResourceSchema$27 = zod.z.object({
|
|
@@ -3410,12 +3526,12 @@ function updateOrganizationMembershipTool$1(proxy) {
|
|
|
3410
3526
|
//#endregion
|
|
3411
3527
|
//#region src/providers/clerk/tools/update-organization-role.ts
|
|
3412
3528
|
const updateOrganizationRoleInputSchema = zod.z.object({
|
|
3413
|
-
organization_role_id: zod.z.string(),
|
|
3529
|
+
organization_role_id: zod.z.string().min(1),
|
|
3414
3530
|
name: zod.z.string().optional(),
|
|
3415
3531
|
key: zod.z.string().optional(),
|
|
3416
3532
|
description: zod.z.string().optional(),
|
|
3417
3533
|
permissions: zod.z.array(zod.z.string()).optional()
|
|
3418
|
-
});
|
|
3534
|
+
}).refine((value) => value.name !== void 0 || value.key !== void 0 || value.description !== void 0 || value.permissions !== void 0, { message: "Provide at least one of name, key, description, or permissions." });
|
|
3419
3535
|
const ResourceSchema$26 = zod.z.object({
|
|
3420
3536
|
id: zod.z.string(),
|
|
3421
3537
|
object: zod.z.string().optional(),
|
|
@@ -3459,7 +3575,8 @@ const updateOrganizationInputSchema$1 = zod.z.object({
|
|
|
3459
3575
|
name: zod.z.string().min(1).optional(),
|
|
3460
3576
|
slug: zod.z.string().optional(),
|
|
3461
3577
|
admin_delete_enabled: zod.z.boolean().optional(),
|
|
3462
|
-
max_allowed_memberships: zod.z.number().int().min(0).optional()
|
|
3578
|
+
max_allowed_memberships: zod.z.number().int().min(0).optional(),
|
|
3579
|
+
public_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3463
3580
|
});
|
|
3464
3581
|
const OrganizationSchema$1 = zod.z.object({
|
|
3465
3582
|
id: zod.z.string(),
|
|
@@ -3491,7 +3608,8 @@ function updateOrganizationTool$1(proxy) {
|
|
|
3491
3608
|
...input.name !== void 0 && { name: input.name },
|
|
3492
3609
|
...input.slug !== void 0 && { slug: input.slug },
|
|
3493
3610
|
...input.admin_delete_enabled !== void 0 && { admin_delete_enabled: input.admin_delete_enabled },
|
|
3494
|
-
...input.max_allowed_memberships !== void 0 && { max_allowed_memberships: input.max_allowed_memberships }
|
|
3611
|
+
...input.max_allowed_memberships !== void 0 && { max_allowed_memberships: input.max_allowed_memberships },
|
|
3612
|
+
...input.public_metadata !== void 0 && { public_metadata: input.public_metadata }
|
|
3495
3613
|
},
|
|
3496
3614
|
retries: 3
|
|
3497
3615
|
});
|
|
@@ -3502,7 +3620,7 @@ function updateOrganizationTool$1(proxy) {
|
|
|
3502
3620
|
//#endregion
|
|
3503
3621
|
//#region src/providers/clerk/tools/update-phone-number.ts
|
|
3504
3622
|
const updatePhoneNumberInputSchema = zod.z.object({
|
|
3505
|
-
phone_number_id: zod.z.string(),
|
|
3623
|
+
phone_number_id: zod.z.string().min(1),
|
|
3506
3624
|
verified: zod.z.boolean().optional(),
|
|
3507
3625
|
primary: zod.z.boolean().optional(),
|
|
3508
3626
|
reserved_for_second_factor: zod.z.boolean().optional()
|
|
@@ -3548,14 +3666,14 @@ function updatePhoneNumberTool(proxy) {
|
|
|
3548
3666
|
//#region src/providers/clerk/tools/update-user.ts
|
|
3549
3667
|
const updateUserInputSchema$1 = zod.z.object({
|
|
3550
3668
|
user_id: zod.z.string().min(1),
|
|
3551
|
-
first_name: zod.z.string().optional(),
|
|
3552
|
-
last_name: zod.z.string().optional(),
|
|
3553
|
-
username: zod.z.string().optional(),
|
|
3669
|
+
first_name: zod.z.string().nullable().optional().describe("Pass null to clear the first name."),
|
|
3670
|
+
last_name: zod.z.string().nullable().optional().describe("Pass null to clear the last name."),
|
|
3671
|
+
username: zod.z.string().nullable().optional().describe("Pass null to clear the username."),
|
|
3554
3672
|
password: zod.z.string().min(8).optional(),
|
|
3555
3673
|
skip_password_checks: zod.z.boolean().optional(),
|
|
3556
3674
|
sign_out_of_other_sessions: zod.z.boolean().optional(),
|
|
3557
|
-
external_id: zod.z.string().optional(),
|
|
3558
|
-
locale: zod.z.string().optional()
|
|
3675
|
+
external_id: zod.z.string().nullable().optional().describe("Pass null to clear the external ID."),
|
|
3676
|
+
locale: zod.z.string().nullable().optional().describe("Pass null to clear the locale.")
|
|
3559
3677
|
});
|
|
3560
3678
|
const UserSchema$24 = zod.z.object({
|
|
3561
3679
|
id: zod.z.string(),
|
|
@@ -3601,24 +3719,30 @@ function updateUserTool$1(proxy) {
|
|
|
3601
3719
|
}
|
|
3602
3720
|
//#endregion
|
|
3603
3721
|
//#region src/providers/clerk/tools/verify-organization-domain.ts
|
|
3722
|
+
const EnrollmentModeSchema = zod.z.enum([
|
|
3723
|
+
"manual_invitation",
|
|
3724
|
+
"automatic_invitation",
|
|
3725
|
+
"automatic_suggestion",
|
|
3726
|
+
"enterprise_sso"
|
|
3727
|
+
]).or(zod.z.string());
|
|
3604
3728
|
const verifyOrganizationDomainInputSchema$1 = zod.z.object({
|
|
3605
|
-
organization_id: zod.z.string(),
|
|
3606
|
-
domain_id: zod.z.string()
|
|
3729
|
+
organization_id: zod.z.string().min(1),
|
|
3730
|
+
domain_id: zod.z.string().min(1)
|
|
3607
3731
|
});
|
|
3608
3732
|
const ResourceSchema$24 = zod.z.object({
|
|
3609
3733
|
id: zod.z.string(),
|
|
3610
3734
|
object: zod.z.string().optional(),
|
|
3611
3735
|
organization_id: zod.z.string().optional(),
|
|
3612
3736
|
name: zod.z.string(),
|
|
3613
|
-
enrollment_mode:
|
|
3737
|
+
enrollment_mode: EnrollmentModeSchema.optional(),
|
|
3614
3738
|
affiliation_verification: zod.z.object({
|
|
3615
3739
|
attempts: zod.z.number().optional(),
|
|
3616
3740
|
status: zod.z.string().optional()
|
|
3617
|
-
}).passthrough().optional(),
|
|
3741
|
+
}).passthrough().nullable().optional(),
|
|
3618
3742
|
verification: zod.z.object({
|
|
3619
3743
|
attempts: zod.z.number().optional(),
|
|
3620
3744
|
status: zod.z.string().optional()
|
|
3621
|
-
}).passthrough().optional(),
|
|
3745
|
+
}).passthrough().nullable().optional(),
|
|
3622
3746
|
verified: zod.z.boolean().optional(),
|
|
3623
3747
|
created_at: zod.z.number().optional(),
|
|
3624
3748
|
updated_at: zod.z.number().optional()
|
|
@@ -3703,8 +3827,25 @@ const clerkProvider = {
|
|
|
3703
3827
|
createTools: createClerkTools
|
|
3704
3828
|
};
|
|
3705
3829
|
//#endregion
|
|
3830
|
+
//#region src/providers/discord/tools/_bot-token.ts
|
|
3831
|
+
/**
|
|
3832
|
+
* Resolves the Discord bot token from the connection's credentials. Nango's
|
|
3833
|
+
* `discord` provider is API_KEY-typed and stores the bot token as its
|
|
3834
|
+
* secret, so the platform serves it back as `credentials.apiKey` (the wire
|
|
3835
|
+
* shape templates are written against). Throws a ToolActionError with a
|
|
3836
|
+
* consistent `missing_credentials` payload so exec bodies don't need to repeat
|
|
3837
|
+
* the guard.
|
|
3838
|
+
*/
|
|
3839
|
+
async function resolveDiscordBotToken(platformProxy) {
|
|
3840
|
+
const credentials = (await platformProxy.getConnectionWithCredentials()).credentials;
|
|
3841
|
+
if (credentials && typeof credentials.apiKey === "string" && credentials.apiKey) return credentials.apiKey;
|
|
3842
|
+
throw new platformProxy.ActionError({
|
|
3843
|
+
type: "missing_credentials",
|
|
3844
|
+
message: "Discord bot token is missing from the connection credentials. Reconnect the discord integration with a valid bot token."
|
|
3845
|
+
});
|
|
3846
|
+
}
|
|
3847
|
+
//#endregion
|
|
3706
3848
|
//#region src/providers/discord/tools/add-guild-member-role.ts
|
|
3707
|
-
const MetadataSchema$7 = zod.z.object({ botToken: zod.z.string() });
|
|
3708
3849
|
const addGuildMemberRoleInputSchema = zod.z.object({
|
|
3709
3850
|
guildId: zod.z.string().describe("Guild ID. Example: \"123456789012345678\""),
|
|
3710
3851
|
userId: zod.z.string().describe("User ID. Example: \"987654321098765432\""),
|
|
@@ -3719,12 +3860,7 @@ function addGuildMemberRoleTool(proxy) {
|
|
|
3719
3860
|
outputSchema: addGuildMemberRoleOutputSchema,
|
|
3720
3861
|
execute: async (input, { requestContext }) => {
|
|
3721
3862
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
3722
|
-
const
|
|
3723
|
-
if (!metadataResult.success) throw new platformProxy.ActionError({
|
|
3724
|
-
type: "invalid_metadata",
|
|
3725
|
-
message: "botToken is required in metadata."
|
|
3726
|
-
});
|
|
3727
|
-
const { botToken } = metadataResult.data;
|
|
3863
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
3728
3864
|
const response = await platformProxy.put({
|
|
3729
3865
|
endpoint: `/api/v10/guilds/${input.guildId}/members/${input.userId}/roles/${input.roleId}`,
|
|
3730
3866
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -3740,7 +3876,6 @@ function addGuildMemberRoleTool(proxy) {
|
|
|
3740
3876
|
}
|
|
3741
3877
|
//#endregion
|
|
3742
3878
|
//#region src/providers/discord/tools/create-channel.ts
|
|
3743
|
-
zod.z.object({ botToken: zod.z.string().describe("Discord bot token from the Discord Developer Portal") });
|
|
3744
3879
|
const createChannelInputSchema$2 = zod.z.object({
|
|
3745
3880
|
guildId: zod.z.string().describe("The ID of the guild to create the channel in. Example: \"41771983423143937\""),
|
|
3746
3881
|
name: zod.z.string().min(1).max(100).describe("Channel name (1-100 characters). Example: \"general\""),
|
|
@@ -3810,11 +3945,7 @@ function createChannelTool$2(proxy) {
|
|
|
3810
3945
|
outputSchema: createChannelOutputSchema$2,
|
|
3811
3946
|
execute: async (input, { requestContext }) => {
|
|
3812
3947
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
3813
|
-
const
|
|
3814
|
-
if (!metadata.botToken) throw new platformProxy.ActionError({
|
|
3815
|
-
type: "invalid_metadata",
|
|
3816
|
-
message: "botToken is required in metadata. Please provide a Discord bot token."
|
|
3817
|
-
});
|
|
3948
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
3818
3949
|
if (!input.guildId) throw new platformProxy.ActionError({
|
|
3819
3950
|
type: "invalid_input",
|
|
3820
3951
|
message: "guildId is required to create a channel."
|
|
@@ -3840,7 +3971,7 @@ function createChannelTool$2(proxy) {
|
|
|
3840
3971
|
const response = await platformProxy.post({
|
|
3841
3972
|
endpoint: `/api/v10/guilds/${input.guildId}/channels`,
|
|
3842
3973
|
data: requestBody,
|
|
3843
|
-
headers: { Authorization: `Bot ${
|
|
3974
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
3844
3975
|
retries: 3
|
|
3845
3976
|
});
|
|
3846
3977
|
const providerChannel = ProviderChannelSchema$10.parse(response.data);
|
|
@@ -3934,11 +4065,7 @@ function createMessageTool(proxy) {
|
|
|
3934
4065
|
outputSchema: createMessageOutputSchema,
|
|
3935
4066
|
execute: async (input, { requestContext }) => {
|
|
3936
4067
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
3937
|
-
const botToken =
|
|
3938
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
3939
|
-
type: "invalid_metadata",
|
|
3940
|
-
message: "botToken is required in connection metadata."
|
|
3941
|
-
});
|
|
4068
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
3942
4069
|
const requestBody = {};
|
|
3943
4070
|
if (input.content !== void 0) requestBody["content"] = input.content;
|
|
3944
4071
|
if (input.embeds !== void 0) requestBody["embeds"] = input.embeds;
|
|
@@ -3990,11 +4117,7 @@ function createReactionTool(proxy) {
|
|
|
3990
4117
|
outputSchema: createReactionOutputSchema,
|
|
3991
4118
|
execute: async (input, { requestContext }) => {
|
|
3992
4119
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
3993
|
-
const botToken =
|
|
3994
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
3995
|
-
type: "invalid_metadata",
|
|
3996
|
-
message: "botToken is required in metadata. Please configure the Discord bot token."
|
|
3997
|
-
});
|
|
4120
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
3998
4121
|
await platformProxy.put({
|
|
3999
4122
|
endpoint: `/api/v10/channels/${input.channel_id}/messages/${input.message_id}/reactions/${encodeURIComponent(input.emoji)}/@me`,
|
|
4000
4123
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -4069,7 +4192,6 @@ const createRoleOutputSchema = zod.z.object({
|
|
|
4069
4192
|
tags: RoleTagsSchema$3.optional(),
|
|
4070
4193
|
flags: zod.z.number().int()
|
|
4071
4194
|
});
|
|
4072
|
-
zod.z.object({ botToken: zod.z.string() });
|
|
4073
4195
|
function createRoleTool(proxy) {
|
|
4074
4196
|
return (0, _mastra_core_tools.createTool)({
|
|
4075
4197
|
id: "discord_create_role",
|
|
@@ -4078,11 +4200,7 @@ function createRoleTool(proxy) {
|
|
|
4078
4200
|
outputSchema: createRoleOutputSchema,
|
|
4079
4201
|
execute: async (input, { requestContext }) => {
|
|
4080
4202
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4081
|
-
const botToken =
|
|
4082
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
4083
|
-
type: "invalid_metadata",
|
|
4084
|
-
message: "botToken is required in metadata."
|
|
4085
|
-
});
|
|
4203
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4086
4204
|
const response = await platformProxy.post({
|
|
4087
4205
|
endpoint: `/api/v10/guilds/${input.guildId}/roles`,
|
|
4088
4206
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -4183,7 +4301,7 @@ function createThreadFromMessageTool(proxy) {
|
|
|
4183
4301
|
outputSchema: createThreadFromMessageOutputSchema,
|
|
4184
4302
|
execute: async (input, { requestContext }) => {
|
|
4185
4303
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4186
|
-
const botToken =
|
|
4304
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4187
4305
|
const requestData = { name: input.name };
|
|
4188
4306
|
if (input.auto_archive_duration !== void 0) requestData["auto_archive_duration"] = input.auto_archive_duration;
|
|
4189
4307
|
if (input.rate_limit_per_user !== void 0) requestData["rate_limit_per_user"] = input.rate_limit_per_user;
|
|
@@ -4257,10 +4375,6 @@ const createWebhookOutputSchema$1 = zod.z.object({
|
|
|
4257
4375
|
token: zod.z.string().optional().describe("Webhook token (only for Incoming webhooks)"),
|
|
4258
4376
|
applicationId: zod.z.string().optional()
|
|
4259
4377
|
});
|
|
4260
|
-
zod.z.object({
|
|
4261
|
-
botToken: zod.z.string().describe("Discord bot token for authentication"),
|
|
4262
|
-
channelId: zod.z.string().optional().describe("Optional default channel ID for creating webhooks")
|
|
4263
|
-
});
|
|
4264
4378
|
function createWebhookTool$1(proxy) {
|
|
4265
4379
|
return (0, _mastra_core_tools.createTool)({
|
|
4266
4380
|
id: "discord_create_webhook",
|
|
@@ -4269,13 +4383,9 @@ function createWebhookTool$1(proxy) {
|
|
|
4269
4383
|
outputSchema: createWebhookOutputSchema$1,
|
|
4270
4384
|
execute: async (input, { requestContext }) => {
|
|
4271
4385
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4386
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4272
4387
|
const metadata = await platformProxy.getMetadata();
|
|
4273
|
-
const botToken = metadata?.botToken;
|
|
4274
4388
|
const channelId = input.channelId ?? metadata?.channelId;
|
|
4275
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
4276
|
-
type: "missing_metadata",
|
|
4277
|
-
message: "botToken is required in connection metadata."
|
|
4278
|
-
});
|
|
4279
4389
|
if (!channelId) throw new platformProxy.ActionError({
|
|
4280
4390
|
type: "missing_channel",
|
|
4281
4391
|
message: "channelId is required in input or metadata."
|
|
@@ -4360,11 +4470,7 @@ function deleteChannelTool$1(proxy) {
|
|
|
4360
4470
|
outputSchema: deleteChannelOutputSchema$1,
|
|
4361
4471
|
execute: async (input, { requestContext }) => {
|
|
4362
4472
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4363
|
-
const botToken =
|
|
4364
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
4365
|
-
type: "invalid_metadata",
|
|
4366
|
-
message: "botToken is required in metadata. Please provide a Discord bot token."
|
|
4367
|
-
});
|
|
4473
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4368
4474
|
const response = await platformProxy.delete({
|
|
4369
4475
|
endpoint: `/api/v10/channels/${input.channelId}`,
|
|
4370
4476
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -4388,7 +4494,6 @@ function deleteChannelTool$1(proxy) {
|
|
|
4388
4494
|
}
|
|
4389
4495
|
//#endregion
|
|
4390
4496
|
//#region src/providers/discord/tools/delete-guild-member.ts
|
|
4391
|
-
zod.z.object({ botToken: zod.z.string().describe("Discord bot token for authentication") });
|
|
4392
4497
|
const deleteGuildMemberInputSchema = zod.z.object({
|
|
4393
4498
|
guild_id: zod.z.string().describe("Guild ID. Example: \"123456789012345678\""),
|
|
4394
4499
|
user_id: zod.z.string().describe("User ID of the member to delete. Example: \"987654321098765432\"")
|
|
@@ -4405,16 +4510,12 @@ function deleteGuildMemberTool(proxy) {
|
|
|
4405
4510
|
outputSchema: deleteGuildMemberOutputSchema,
|
|
4406
4511
|
execute: async (input, { requestContext }) => {
|
|
4407
4512
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4408
|
-
const
|
|
4409
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
4410
|
-
type: "invalid_metadata",
|
|
4411
|
-
message: "botToken is required in connection metadata"
|
|
4412
|
-
});
|
|
4513
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4413
4514
|
let response;
|
|
4414
4515
|
try {
|
|
4415
4516
|
response = await platformProxy.delete({
|
|
4416
4517
|
endpoint: `/api/v10/guilds/${input.guild_id}/members/${input.user_id}`,
|
|
4417
|
-
headers: { Authorization: `Bot ${
|
|
4518
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
4418
4519
|
retries: 1
|
|
4419
4520
|
});
|
|
4420
4521
|
} catch (err) {
|
|
@@ -4437,7 +4538,6 @@ function deleteGuildMemberTool(proxy) {
|
|
|
4437
4538
|
}
|
|
4438
4539
|
//#endregion
|
|
4439
4540
|
//#region src/providers/discord/tools/delete-guild.ts
|
|
4440
|
-
const MetadataSchema$6 = zod.z.object({ botToken: zod.z.string().describe("Discord bot token from the Discord Developer Portal") });
|
|
4441
4541
|
const deleteGuildInputSchema = zod.z.object({ guild_id: zod.z.string().describe("The ID of the guild for the bot to leave.") });
|
|
4442
4542
|
const deleteGuildOutputSchema = zod.z.object({
|
|
4443
4543
|
success: zod.z.boolean().describe("Whether the bot successfully left the guild"),
|
|
@@ -4451,13 +4551,7 @@ function deleteGuildTool(proxy) {
|
|
|
4451
4551
|
outputSchema: deleteGuildOutputSchema,
|
|
4452
4552
|
execute: async (input, { requestContext }) => {
|
|
4453
4553
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4454
|
-
const
|
|
4455
|
-
const parsedMetadata = MetadataSchema$6.safeParse(metadata);
|
|
4456
|
-
if (!parsedMetadata.success) throw new platformProxy.ActionError({
|
|
4457
|
-
type: "invalid_metadata",
|
|
4458
|
-
message: "botToken is required in metadata. Please configure the bot token in the connection metadata."
|
|
4459
|
-
});
|
|
4460
|
-
const botToken = parsedMetadata.data.botToken;
|
|
4554
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4461
4555
|
const response = await platformProxy.delete({
|
|
4462
4556
|
endpoint: `/api/v10/users/@me/guilds/${input.guild_id}`,
|
|
4463
4557
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -4477,7 +4571,6 @@ function deleteGuildTool(proxy) {
|
|
|
4477
4571
|
}
|
|
4478
4572
|
//#endregion
|
|
4479
4573
|
//#region src/providers/discord/tools/delete-message.ts
|
|
4480
|
-
const MetadataSchema$5 = zod.z.object({ botToken: zod.z.string().describe("Discord bot token") });
|
|
4481
4574
|
const deleteMessageInputSchema$2 = zod.z.object({
|
|
4482
4575
|
channelId: zod.z.string().describe("Channel ID where the message exists. Example: \"1234567890123456789\""),
|
|
4483
4576
|
messageId: zod.z.string().describe("Message ID to delete. Example: \"9876543210987654321\"")
|
|
@@ -4495,12 +4588,7 @@ function deleteMessageTool$2(proxy) {
|
|
|
4495
4588
|
outputSchema: deleteMessageOutputSchema$2,
|
|
4496
4589
|
execute: async (input, { requestContext }) => {
|
|
4497
4590
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4498
|
-
const
|
|
4499
|
-
if (!metadata.success) throw new platformProxy.ActionError({
|
|
4500
|
-
type: "invalid_metadata",
|
|
4501
|
-
message: "Invalid metadata: botToken is required."
|
|
4502
|
-
});
|
|
4503
|
-
const botToken = metadata.data.botToken;
|
|
4591
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4504
4592
|
await platformProxy.delete({
|
|
4505
4593
|
endpoint: `/api/v10/channels/${input.channelId}/messages/${input.messageId}`,
|
|
4506
4594
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -4530,11 +4618,7 @@ function deleteReactionTool(proxy) {
|
|
|
4530
4618
|
outputSchema: deleteReactionOutputSchema,
|
|
4531
4619
|
execute: async (input, { requestContext }) => {
|
|
4532
4620
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4533
|
-
const botToken =
|
|
4534
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
4535
|
-
type: "invalid_metadata",
|
|
4536
|
-
message: "botToken is required in metadata. Please configure the bot token from Discord Developer Portal."
|
|
4537
|
-
});
|
|
4621
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4538
4622
|
await platformProxy.delete({
|
|
4539
4623
|
endpoint: `/api/v10/channels/${input.channel_id}/messages/${input.message_id}/reactions/${encodeURIComponent(input.emoji)}/@me`,
|
|
4540
4624
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -4576,7 +4660,7 @@ function deleteRoleTool(proxy) {
|
|
|
4576
4660
|
outputSchema: deleteRoleOutputSchema,
|
|
4577
4661
|
execute: async (input, { requestContext }) => {
|
|
4578
4662
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4579
|
-
const botToken =
|
|
4663
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4580
4664
|
if (!botToken) throw new platformProxy.ActionError({
|
|
4581
4665
|
type: "invalid_metadata",
|
|
4582
4666
|
message: "botToken is required in metadata. Please provide the Discord bot token from your Discord application settings."
|
|
@@ -4610,11 +4694,7 @@ function deleteWebhookTool$1(proxy) {
|
|
|
4610
4694
|
outputSchema: deleteWebhookOutputSchema$1,
|
|
4611
4695
|
execute: async (input, { requestContext }) => {
|
|
4612
4696
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4613
|
-
const botToken =
|
|
4614
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
4615
|
-
type: "invalid_metadata",
|
|
4616
|
-
message: "botToken is required in metadata. Please ensure the Discord connection has a botToken configured."
|
|
4617
|
-
});
|
|
4697
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4618
4698
|
const response = await platformProxy.delete({
|
|
4619
4699
|
endpoint: `/api/v10/webhooks/${input.webhookId}`,
|
|
4620
4700
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -4718,14 +4798,10 @@ function getChannelTool$2(proxy) {
|
|
|
4718
4798
|
outputSchema: getChannelOutputSchema$2,
|
|
4719
4799
|
execute: async (input, { requestContext }) => {
|
|
4720
4800
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4721
|
-
const
|
|
4722
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
4723
|
-
type: "invalid_metadata",
|
|
4724
|
-
message: "botToken is required in metadata. Please set up the connection with botToken in metadata."
|
|
4725
|
-
});
|
|
4801
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4726
4802
|
const response = await platformProxy.get({
|
|
4727
4803
|
endpoint: `/api/v10/channels/${input.channelId}`,
|
|
4728
|
-
headers: { Authorization: `Bot ${
|
|
4804
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
4729
4805
|
retries: 3
|
|
4730
4806
|
});
|
|
4731
4807
|
if (!response.data) throw new platformProxy.ActionError({
|
|
@@ -4824,14 +4900,10 @@ function getGuildMemberTool(proxy) {
|
|
|
4824
4900
|
outputSchema: getGuildMemberOutputSchema,
|
|
4825
4901
|
execute: async (input, { requestContext }) => {
|
|
4826
4902
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4827
|
-
const
|
|
4828
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
4829
|
-
type: "invalid_metadata",
|
|
4830
|
-
message: "botToken is required in metadata."
|
|
4831
|
-
});
|
|
4903
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4832
4904
|
const response = await platformProxy.get({
|
|
4833
4905
|
endpoint: `/api/v10/guilds/${input.guild_id}/members/${input.user_id}`,
|
|
4834
|
-
headers: { Authorization: `Bot ${
|
|
4906
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
4835
4907
|
retries: 3
|
|
4836
4908
|
});
|
|
4837
4909
|
if (response.status === 404) throw new platformProxy.ActionError({
|
|
@@ -4874,11 +4946,7 @@ function getGuildTool(proxy) {
|
|
|
4874
4946
|
outputSchema: getGuildOutputSchema,
|
|
4875
4947
|
execute: async (input, { requestContext }) => {
|
|
4876
4948
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4877
|
-
const botToken =
|
|
4878
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
4879
|
-
type: "invalid_metadata",
|
|
4880
|
-
message: "botToken is required in metadata. Please configure the bot token from Discord Developer Portal."
|
|
4881
|
-
});
|
|
4949
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4882
4950
|
const response = await platformProxy.get({
|
|
4883
4951
|
endpoint: `/api/v10/guilds/${input.guildId}`,
|
|
4884
4952
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -4989,14 +5057,10 @@ function getMessageTool$1(proxy) {
|
|
|
4989
5057
|
outputSchema: getMessageOutputSchema$1,
|
|
4990
5058
|
execute: async (input, { requestContext }) => {
|
|
4991
5059
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
4992
|
-
const
|
|
4993
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
4994
|
-
type: "invalid_metadata",
|
|
4995
|
-
message: "botToken is required in metadata."
|
|
4996
|
-
});
|
|
5060
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
4997
5061
|
const response = await platformProxy.get({
|
|
4998
5062
|
endpoint: `/api/v10/channels/${input.channelId}/messages/${input.messageId}`,
|
|
4999
|
-
headers: { Authorization: `Bot ${
|
|
5063
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
5000
5064
|
retries: 3
|
|
5001
5065
|
});
|
|
5002
5066
|
if (!response.data) throw new platformProxy.ActionError({
|
|
@@ -5107,14 +5171,10 @@ function getRoleTool(proxy) {
|
|
|
5107
5171
|
outputSchema: getRoleOutputSchema,
|
|
5108
5172
|
execute: async (input, { requestContext }) => {
|
|
5109
5173
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5110
|
-
const
|
|
5111
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
5112
|
-
type: "invalid_metadata",
|
|
5113
|
-
message: "botToken is required in metadata."
|
|
5114
|
-
});
|
|
5174
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5115
5175
|
const response = await platformProxy.get({
|
|
5116
5176
|
endpoint: `/api/v10/guilds/${input.guild_id}/roles/${input.role_id}`,
|
|
5117
|
-
headers: { Authorization: `Bot ${
|
|
5177
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
5118
5178
|
retries: 3
|
|
5119
5179
|
});
|
|
5120
5180
|
if (!response.data) throw new platformProxy.ActionError({
|
|
@@ -5189,14 +5249,10 @@ function getWebhookTool$1(proxy) {
|
|
|
5189
5249
|
outputSchema: getWebhookOutputSchema$1,
|
|
5190
5250
|
execute: async (input, { requestContext }) => {
|
|
5191
5251
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5192
|
-
const
|
|
5193
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
5194
|
-
type: "invalid_metadata",
|
|
5195
|
-
message: "botToken is required in connection metadata."
|
|
5196
|
-
});
|
|
5252
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5197
5253
|
const response = await platformProxy.get({
|
|
5198
5254
|
endpoint: `/api/v10/webhooks/${input.webhookId}`,
|
|
5199
|
-
headers: { Authorization: `Bot ${
|
|
5255
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
5200
5256
|
retries: 3
|
|
5201
5257
|
});
|
|
5202
5258
|
if (!response.data) throw new platformProxy.ActionError({
|
|
@@ -5244,7 +5300,7 @@ const ChannelSchema$2 = zod.z.object({
|
|
|
5244
5300
|
recipients: zod.z.array(zod.z.unknown()).optional(),
|
|
5245
5301
|
icon: zod.z.string().nullable().optional(),
|
|
5246
5302
|
owner_id: zod.z.string().optional(),
|
|
5247
|
-
application_id: zod.z.string().optional(),
|
|
5303
|
+
application_id: zod.z.string().nullable().optional(),
|
|
5248
5304
|
managed: zod.z.boolean().optional(),
|
|
5249
5305
|
parent_id: zod.z.string().nullable().optional(),
|
|
5250
5306
|
last_pin_timestamp: zod.z.string().nullable().optional(),
|
|
@@ -5267,7 +5323,7 @@ function listChannelsTool$2(proxy) {
|
|
|
5267
5323
|
outputSchema: listChannelsOutputSchema$2,
|
|
5268
5324
|
execute: async (input, { requestContext }) => {
|
|
5269
5325
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5270
|
-
const botToken =
|
|
5326
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5271
5327
|
if (!botToken) throw new platformProxy.ActionError({
|
|
5272
5328
|
type: "invalid_metadata",
|
|
5273
5329
|
message: "botToken is required in metadata. Please configure the Discord connection with a bot token from your Discord application settings."
|
|
@@ -5360,12 +5416,7 @@ function listGuildMembersTool(proxy) {
|
|
|
5360
5416
|
outputSchema: listGuildMembersOutputSchema,
|
|
5361
5417
|
execute: async (input, { requestContext }) => {
|
|
5362
5418
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5363
|
-
const
|
|
5364
|
-
const parsedMetadata = zod.z.object({ botToken: zod.z.string() }).safeParse(metadata);
|
|
5365
|
-
if (!parsedMetadata.success) throw new platformProxy.ActionError({
|
|
5366
|
-
type: "missing_bot_token",
|
|
5367
|
-
message: "botToken is required in connection metadata."
|
|
5368
|
-
});
|
|
5419
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5369
5420
|
const limit = input.limit ?? 100;
|
|
5370
5421
|
const response = await platformProxy.get({
|
|
5371
5422
|
endpoint: `/api/v10/guilds/${input.guild_id}/members`,
|
|
@@ -5373,7 +5424,7 @@ function listGuildMembersTool(proxy) {
|
|
|
5373
5424
|
limit: String(limit),
|
|
5374
5425
|
...input.after !== void 0 && { after: input.after }
|
|
5375
5426
|
},
|
|
5376
|
-
headers: { Authorization: `Bot ${
|
|
5427
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
5377
5428
|
retries: 3
|
|
5378
5429
|
});
|
|
5379
5430
|
const rawMembers = zod.z.array(zod.z.unknown()).parse(response.data);
|
|
@@ -5443,11 +5494,7 @@ function listGuildsTool(proxy) {
|
|
|
5443
5494
|
outputSchema: listGuildsOutputSchema,
|
|
5444
5495
|
execute: async (input, { requestContext }) => {
|
|
5445
5496
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5446
|
-
const botToken =
|
|
5447
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
5448
|
-
type: "invalid_metadata",
|
|
5449
|
-
message: "botToken is required in metadata."
|
|
5450
|
-
});
|
|
5497
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5451
5498
|
const limit = input.limit ?? 200;
|
|
5452
5499
|
const response = await platformProxy.get({
|
|
5453
5500
|
endpoint: "/api/v10/users/@me/guilds",
|
|
@@ -5566,7 +5613,7 @@ function listMessagesTool$1(proxy) {
|
|
|
5566
5613
|
outputSchema: listMessagesOutputSchema$1,
|
|
5567
5614
|
execute: async (input, { requestContext }) => {
|
|
5568
5615
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5569
|
-
const botToken =
|
|
5616
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5570
5617
|
if (!botToken) throw new platformProxy.ActionError({
|
|
5571
5618
|
type: "missing_bot_token",
|
|
5572
5619
|
message: "Bot token is required in connection metadata. Please configure the bot token in your Nango connection."
|
|
@@ -5681,11 +5728,7 @@ function listRolesTool$1(proxy) {
|
|
|
5681
5728
|
outputSchema: listRolesOutputSchema$1,
|
|
5682
5729
|
execute: async (input, { requestContext }) => {
|
|
5683
5730
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5684
|
-
const botToken =
|
|
5685
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
5686
|
-
type: "invalid_metadata",
|
|
5687
|
-
message: "botToken is required in metadata."
|
|
5688
|
-
});
|
|
5731
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5689
5732
|
const response = await platformProxy.get({
|
|
5690
5733
|
endpoint: `/api/v10/guilds/${input.guild_id}/roles`,
|
|
5691
5734
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -5745,7 +5788,6 @@ const WebhookSchema = zod.z.object({
|
|
|
5745
5788
|
url: zod.z.string().optional()
|
|
5746
5789
|
});
|
|
5747
5790
|
const listWebhooksOutputSchema$1 = zod.z.object({ webhooks: zod.z.array(WebhookSchema) });
|
|
5748
|
-
zod.z.object({ botToken: zod.z.string() });
|
|
5749
5791
|
function listWebhooksTool$1(proxy) {
|
|
5750
5792
|
return (0, _mastra_core_tools.createTool)({
|
|
5751
5793
|
id: "discord_list_webhooks",
|
|
@@ -5754,14 +5796,10 @@ function listWebhooksTool$1(proxy) {
|
|
|
5754
5796
|
outputSchema: listWebhooksOutputSchema$1,
|
|
5755
5797
|
execute: async (input, { requestContext }) => {
|
|
5756
5798
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5757
|
-
const
|
|
5758
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
5759
|
-
type: "missing_bot_token",
|
|
5760
|
-
message: "Bot token is required in connection metadata."
|
|
5761
|
-
});
|
|
5799
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5762
5800
|
const response = await platformProxy.get({
|
|
5763
5801
|
endpoint: `/api/v10/channels/${input.channelId}/webhooks`,
|
|
5764
|
-
headers: { Authorization: `Bot ${
|
|
5802
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
5765
5803
|
retries: 3
|
|
5766
5804
|
});
|
|
5767
5805
|
return { webhooks: zod.z.array(WebhookSchema).parse(response.data) };
|
|
@@ -5789,11 +5827,7 @@ function removeGuildMemberRoleTool(proxy) {
|
|
|
5789
5827
|
outputSchema: removeGuildMemberRoleOutputSchema,
|
|
5790
5828
|
execute: async (input, { requestContext }) => {
|
|
5791
5829
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5792
|
-
const botToken =
|
|
5793
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
5794
|
-
type: "missing_bot_token",
|
|
5795
|
-
message: "Bot token is required in metadata. Please configure the botToken in your connection metadata."
|
|
5796
|
-
});
|
|
5830
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5797
5831
|
const response = await platformProxy.delete({
|
|
5798
5832
|
endpoint: `/api/v10/guilds/${input.guild_id}/members/${input.user_id}/roles/${input.role_id}`,
|
|
5799
5833
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -5859,7 +5893,6 @@ const ProviderChannelSchema$7 = zod.z.object({
|
|
|
5859
5893
|
default_auto_archive_duration: zod.z.number().int().optional(),
|
|
5860
5894
|
flags: zod.z.number().int().optional()
|
|
5861
5895
|
});
|
|
5862
|
-
const MetadataSchema$4 = zod.z.object({ botToken: zod.z.string() });
|
|
5863
5896
|
const updateChannelOutputSchema$1 = zod.z.object({
|
|
5864
5897
|
id: zod.z.string(),
|
|
5865
5898
|
type: zod.z.number().int(),
|
|
@@ -5890,12 +5923,7 @@ function updateChannelTool$1(proxy) {
|
|
|
5890
5923
|
outputSchema: updateChannelOutputSchema$1,
|
|
5891
5924
|
execute: async (input, { requestContext }) => {
|
|
5892
5925
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
5893
|
-
const
|
|
5894
|
-
const metadata = MetadataSchema$4.safeParse(rawMetadata);
|
|
5895
|
-
if (!metadata.success || !metadata.data.botToken) throw new platformProxy.ActionError({
|
|
5896
|
-
type: "invalid_metadata",
|
|
5897
|
-
message: "botToken is required in metadata. Please set the Discord bot token in the connection metadata."
|
|
5898
|
-
});
|
|
5926
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
5899
5927
|
const updateData = {};
|
|
5900
5928
|
if (input["name"] !== void 0) updateData["name"] = input["name"];
|
|
5901
5929
|
if (input["type"] !== void 0) updateData["type"] = input["type"];
|
|
@@ -5911,7 +5939,7 @@ function updateChannelTool$1(proxy) {
|
|
|
5911
5939
|
if (input["flags"] !== void 0) updateData["flags"] = input["flags"];
|
|
5912
5940
|
const response = await platformProxy.patch({
|
|
5913
5941
|
endpoint: `/api/v10/channels/${input.channel_id}`,
|
|
5914
|
-
headers: { Authorization: `Bot ${
|
|
5942
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
5915
5943
|
data: updateData,
|
|
5916
5944
|
retries: 10
|
|
5917
5945
|
});
|
|
@@ -6019,11 +6047,7 @@ function updateGuildMemberTool(proxy) {
|
|
|
6019
6047
|
outputSchema: updateGuildMemberOutputSchema,
|
|
6020
6048
|
execute: async (input, { requestContext }) => {
|
|
6021
6049
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
6022
|
-
const
|
|
6023
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
6024
|
-
type: "invalid_metadata",
|
|
6025
|
-
message: "botToken is required in metadata. Please provide the bot token from your Discord application."
|
|
6026
|
-
});
|
|
6050
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
6027
6051
|
const body = {};
|
|
6028
6052
|
if (input["nick"] !== void 0) body["nick"] = input["nick"];
|
|
6029
6053
|
if (input["roles"] !== void 0) body["roles"] = input["roles"];
|
|
@@ -6032,7 +6056,7 @@ function updateGuildMemberTool(proxy) {
|
|
|
6032
6056
|
if (input["channel_id"] !== void 0) body["channel_id"] = input["channel_id"];
|
|
6033
6057
|
if (input["communication_disabled_until"] !== void 0) body["communication_disabled_until"] = input["communication_disabled_until"];
|
|
6034
6058
|
if (input["flags"] !== void 0) body["flags"] = input["flags"];
|
|
6035
|
-
const headers = { Authorization: `Bot ${
|
|
6059
|
+
const headers = { Authorization: `Bot ${botToken}` };
|
|
6036
6060
|
if (input.reason) headers["X-Audit-Log-Reason"] = input.reason;
|
|
6037
6061
|
if (input["user_id"] === "@me") {
|
|
6038
6062
|
const currentMemberBody = {};
|
|
@@ -6083,7 +6107,6 @@ function updateGuildMemberTool(proxy) {
|
|
|
6083
6107
|
}
|
|
6084
6108
|
//#endregion
|
|
6085
6109
|
//#region src/providers/discord/tools/update-guild.ts
|
|
6086
|
-
zod.z.object({ botToken: zod.z.string() });
|
|
6087
6110
|
const updateGuildInputSchema = zod.z.object({
|
|
6088
6111
|
guild_id: zod.z.string().describe("Guild ID to update. Example: \"197038439483310086\""),
|
|
6089
6112
|
name: zod.z.string().min(2).max(100).optional().describe("Guild name (2-100 characters)"),
|
|
@@ -6139,11 +6162,7 @@ function updateGuildTool(proxy) {
|
|
|
6139
6162
|
outputSchema: updateGuildOutputSchema,
|
|
6140
6163
|
execute: async (input, { requestContext }) => {
|
|
6141
6164
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
6142
|
-
const
|
|
6143
|
-
if (!metadata?.botToken) throw new platformProxy.ActionError({
|
|
6144
|
-
type: "invalid_metadata",
|
|
6145
|
-
message: "botToken is required in metadata."
|
|
6146
|
-
});
|
|
6165
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
6147
6166
|
const payload = {};
|
|
6148
6167
|
if (input.name !== void 0) payload["name"] = input.name;
|
|
6149
6168
|
if (input.region !== void 0) payload["region"] = input.region;
|
|
@@ -6168,7 +6187,7 @@ function updateGuildTool(proxy) {
|
|
|
6168
6187
|
if (input.safety_alerts_channel_id !== void 0) payload["safety_alerts_channel_id"] = input.safety_alerts_channel_id;
|
|
6169
6188
|
const response = await platformProxy.patch({
|
|
6170
6189
|
endpoint: `/api/v10/guilds/${input.guild_id}`,
|
|
6171
|
-
headers: { Authorization: `Bot ${
|
|
6190
|
+
headers: { Authorization: `Bot ${botToken}` },
|
|
6172
6191
|
data: payload,
|
|
6173
6192
|
retries: 3
|
|
6174
6193
|
});
|
|
@@ -6277,13 +6296,7 @@ function updateMessageTool$1(proxy) {
|
|
|
6277
6296
|
outputSchema: updateMessageOutputSchema$1,
|
|
6278
6297
|
execute: async (input, { requestContext }) => {
|
|
6279
6298
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
6280
|
-
const
|
|
6281
|
-
const parsedMetadata = zod.z.object({ botToken: zod.z.string() }).safeParse(metadata);
|
|
6282
|
-
if (!parsedMetadata.success) throw new platformProxy.ActionError({
|
|
6283
|
-
type: "invalid_metadata",
|
|
6284
|
-
message: "botToken is required in metadata."
|
|
6285
|
-
});
|
|
6286
|
-
const botToken = parsedMetadata.data.botToken;
|
|
6299
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
6287
6300
|
const response = await platformProxy.patch({
|
|
6288
6301
|
endpoint: `/api/v10/channels/${input.channel_id}/messages/${input.message_id}`,
|
|
6289
6302
|
headers: { Authorization: `Bot ${botToken}` },
|
|
@@ -6369,11 +6382,7 @@ function updateRoleTool(proxy) {
|
|
|
6369
6382
|
outputSchema: updateRoleOutputSchema,
|
|
6370
6383
|
execute: async (input, { requestContext }) => {
|
|
6371
6384
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
6372
|
-
const botToken =
|
|
6373
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
6374
|
-
type: "invalid_metadata",
|
|
6375
|
-
message: "botToken is required in metadata."
|
|
6376
|
-
});
|
|
6385
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
6377
6386
|
if (input.icon !== void 0 && input.icon !== null && input.unicodeEmoji !== void 0 && input.unicodeEmoji !== null) throw new platformProxy.ActionError({
|
|
6378
6387
|
type: "invalid_input",
|
|
6379
6388
|
message: "icon and unicodeEmoji are mutually exclusive; provide at most one."
|
|
@@ -6456,12 +6465,7 @@ function updateWebhookTool$1(proxy) {
|
|
|
6456
6465
|
outputSchema: updateWebhookOutputSchema$1,
|
|
6457
6466
|
execute: async (input, { requestContext }) => {
|
|
6458
6467
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
6459
|
-
const
|
|
6460
|
-
const botToken = metadata && typeof metadata === "object" && "botToken" in metadata && typeof metadata.botToken === "string" ? metadata.botToken : void 0;
|
|
6461
|
-
if (!botToken) throw new platformProxy.ActionError({
|
|
6462
|
-
type: "invalid_metadata",
|
|
6463
|
-
message: "botToken is required in metadata."
|
|
6464
|
-
});
|
|
6468
|
+
const botToken = await resolveDiscordBotToken(platformProxy);
|
|
6465
6469
|
const requestBody = {};
|
|
6466
6470
|
if (input.name !== void 0) requestBody["name"] = input.name;
|
|
6467
6471
|
if (input.avatar !== void 0) requestBody["avatar"] = input.avatar;
|
|
@@ -55361,7 +55365,7 @@ const cancelEmailInputSchema = zod.z.object({ email_id: zod.z.string() });
|
|
|
55361
55365
|
const ProviderResponseSchema$107 = zod.z.object({
|
|
55362
55366
|
object: zod.z.string().optional(),
|
|
55363
55367
|
id: zod.z.string().optional(),
|
|
55364
|
-
message_id: zod.z.string().optional(),
|
|
55368
|
+
message_id: zod.z.string().nullable().optional(),
|
|
55365
55369
|
to: zod.z.array(zod.z.string()).optional(),
|
|
55366
55370
|
from: zod.z.string().optional(),
|
|
55367
55371
|
created_at: zod.z.string().optional(),
|
|
@@ -56611,7 +56615,7 @@ const getEmailInputSchema = zod.z.object({ email_id: zod.z.string() });
|
|
|
56611
56615
|
const ProviderResponseSchema$76 = zod.z.object({
|
|
56612
56616
|
object: zod.z.string().optional(),
|
|
56613
56617
|
id: zod.z.string().optional(),
|
|
56614
|
-
message_id: zod.z.string().optional(),
|
|
56618
|
+
message_id: zod.z.string().nullable().optional(),
|
|
56615
56619
|
to: zod.z.array(zod.z.string()).optional(),
|
|
56616
56620
|
from: zod.z.string().optional(),
|
|
56617
56621
|
created_at: zod.z.string().optional(),
|
|
@@ -56698,7 +56702,7 @@ const ProviderResponseSchema$74 = zod.z.object({
|
|
|
56698
56702
|
to: zod.z.array(zod.z.string()).optional(),
|
|
56699
56703
|
from: zod.z.string().optional(),
|
|
56700
56704
|
subject: zod.z.string().optional(),
|
|
56701
|
-
message_id: zod.z.string().optional(),
|
|
56705
|
+
message_id: zod.z.string().nullable().optional(),
|
|
56702
56706
|
bcc: zod.z.array(zod.z.string()).nullable().optional(),
|
|
56703
56707
|
cc: zod.z.array(zod.z.string()).nullable().optional(),
|
|
56704
56708
|
reply_to: zod.z.array(zod.z.string()).nullable().optional(),
|
|
@@ -56772,7 +56776,7 @@ const ProviderResponseSchema$72 = zod.z.object({
|
|
|
56772
56776
|
current_version_id: zod.z.string().optional(),
|
|
56773
56777
|
name: zod.z.string().optional(),
|
|
56774
56778
|
alias: zod.z.string().optional(),
|
|
56775
|
-
from: zod.z.string().optional(),
|
|
56779
|
+
from: zod.z.string().nullable().optional(),
|
|
56776
56780
|
subject: zod.z.string().optional(),
|
|
56777
56781
|
reply_to: zod.z.array(zod.z.string()).nullable().optional(),
|
|
56778
56782
|
html: zod.z.string().optional(),
|
|
@@ -57495,7 +57499,7 @@ const ProviderResponseSchema$57 = zod.z.object({
|
|
|
57495
57499
|
data: zod.z.array(zod.z.object({
|
|
57496
57500
|
object: zod.z.string().optional(),
|
|
57497
57501
|
id: zod.z.string().optional(),
|
|
57498
|
-
message_id: zod.z.string().optional(),
|
|
57502
|
+
message_id: zod.z.string().nullable().optional(),
|
|
57499
57503
|
to: zod.z.array(zod.z.string()).optional(),
|
|
57500
57504
|
from: zod.z.string().optional(),
|
|
57501
57505
|
created_at: zod.z.string().optional(),
|
|
@@ -57614,7 +57618,7 @@ const ProviderResponseSchema$55 = zod.z.object({
|
|
|
57614
57618
|
to: zod.z.array(zod.z.string()).optional(),
|
|
57615
57619
|
from: zod.z.string().optional(),
|
|
57616
57620
|
subject: zod.z.string().nullable().optional(),
|
|
57617
|
-
message_id: zod.z.string().optional(),
|
|
57621
|
+
message_id: zod.z.string().nullable().optional(),
|
|
57618
57622
|
bcc: zod.z.array(zod.z.string()).nullable().optional(),
|
|
57619
57623
|
cc: zod.z.array(zod.z.string()).nullable().optional(),
|
|
57620
57624
|
reply_to: zod.z.array(zod.z.string()).nullable().optional(),
|
|
@@ -58302,7 +58306,7 @@ function updateContactTopicsTool(proxy) {
|
|
|
58302
58306
|
const config = {
|
|
58303
58307
|
endpoint: `/contacts/${encodeURIComponent(input["contact_id"])}/topics`,
|
|
58304
58308
|
retries: 3,
|
|
58305
|
-
data: input.body
|
|
58309
|
+
data: input.body.topics
|
|
58306
58310
|
};
|
|
58307
58311
|
const response = await platformProxy.patch(config);
|
|
58308
58312
|
return ProviderResponseSchema$39.parse(response.data);
|
|
@@ -74254,8 +74258,10 @@ let nextResolverId = 0;
|
|
|
74254
74258
|
* to (or detached from) the project are picked up (or dropped) without a
|
|
74255
74259
|
* restart.
|
|
74256
74260
|
*
|
|
74257
|
-
* Configuration errors (missing project id, bad ttlMs, malformed integration id
|
|
74258
|
-
* throw here — at call time — so they
|
|
74261
|
+
* Configuration errors (missing project id, bad ttlMs, malformed integration id,
|
|
74262
|
+
* the removed `autoApproveTools` key) throw here — at call time — so they
|
|
74263
|
+
* surface at startup. Configuration errors that need discovery to detect
|
|
74264
|
+
* (an unknown tool name in `requireApproval`) fail the resolution instead.
|
|
74259
74265
|
* Expected provider absence is silently skipped. Actionable per-integration
|
|
74260
74266
|
* problems during resolution (needs re-auth or ambiguity) are downgraded to
|
|
74261
74267
|
* warn-and-skip so one bad integration never takes down the whole toolset.
|
|
@@ -74271,6 +74277,8 @@ function tools(options = {}) {
|
|
|
74271
74277
|
const integrationOverrides = normalizeIntegrationOverrides(options.integrations);
|
|
74272
74278
|
validateIntegrationOverrides(integrationOverrides);
|
|
74273
74279
|
validateIntegrationXor(integrationOverrides);
|
|
74280
|
+
validateRequireApproval(integrationOverrides);
|
|
74281
|
+
rejectRemovedAutoApproveTools(integrationOverrides);
|
|
74274
74282
|
let cache;
|
|
74275
74283
|
let inflight;
|
|
74276
74284
|
let closing;
|
|
@@ -74389,6 +74397,30 @@ function validateIntegrationXor(integrations) {
|
|
|
74389
74397
|
if (filters.allowTools !== void 0 && filters.disallowTools !== void 0) throw new MastraConnectError("invalid_options", `Invalid options for '${integrationId}': allowTools and disallowTools are mutually exclusive; set at most one.`);
|
|
74390
74398
|
}
|
|
74391
74399
|
}
|
|
74400
|
+
/**
|
|
74401
|
+
* Rejects a `requireApproval` value that is not a boolean or an array of
|
|
74402
|
+
* string tool keys. The approval branches check for literal `true` or an
|
|
74403
|
+
* array, so a loosely typed value like `'true'` would otherwise disable
|
|
74404
|
+
* approval on MCP providers silently (and crash the HTTP path into
|
|
74405
|
+
* warn-and-skip) instead of gating tools as the author intended.
|
|
74406
|
+
*/
|
|
74407
|
+
function validateRequireApproval(integrations) {
|
|
74408
|
+
for (const [integrationId, providerOptions] of Object.entries(integrations)) {
|
|
74409
|
+
const requireApproval = providerOptions.requireApproval;
|
|
74410
|
+
if (requireApproval === void 0 || typeof requireApproval === "boolean") continue;
|
|
74411
|
+
if (Array.isArray(requireApproval) && requireApproval.every((name) => typeof name === "string")) continue;
|
|
74412
|
+
throw new MastraConnectError("invalid_options", `Invalid options for '${integrationId}': requireApproval must be a boolean or an array of tool keys.`);
|
|
74413
|
+
}
|
|
74414
|
+
}
|
|
74415
|
+
/**
|
|
74416
|
+
* Rejects the removed `autoApproveTools` option by name. Discovered MCP tools
|
|
74417
|
+
* no longer require approval by default, so a loosely typed config still
|
|
74418
|
+
* carrying this key would otherwise be ignored silently and its tools would
|
|
74419
|
+
* run without the prompts the author expected.
|
|
74420
|
+
*/
|
|
74421
|
+
function rejectRemovedAutoApproveTools(integrations) {
|
|
74422
|
+
for (const [integrationId, providerOptions] of Object.entries(integrations)) if ("autoApproveTools" in providerOptions) throw new MastraConnectError("invalid_options", `Invalid options for '${integrationId}': autoApproveTools was removed. Tools no longer require approval by default; opt in with requireApproval: true or a list of tool keys to gate.`);
|
|
74423
|
+
}
|
|
74392
74424
|
function buildRequests(integrations, catalog) {
|
|
74393
74425
|
const overrides = integrations;
|
|
74394
74426
|
const registrations = new Map(TOOLS.map((registration) => [registration.integrationId, registration]));
|
|
@@ -74438,16 +74470,19 @@ async function mapTools(connections, requests, options, client, mcpClients, reso
|
|
|
74438
74470
|
connectionId: resolution.connectionId,
|
|
74439
74471
|
allowTools: request.options.allowTools,
|
|
74440
74472
|
disallowTools: request.options.disallowTools,
|
|
74441
|
-
|
|
74473
|
+
requireApproval: request.options.requireApproval,
|
|
74442
74474
|
client,
|
|
74443
74475
|
mcpClients,
|
|
74444
74476
|
resolverId
|
|
74445
74477
|
});
|
|
74446
|
-
} else
|
|
74447
|
-
|
|
74448
|
-
|
|
74449
|
-
|
|
74450
|
-
|
|
74478
|
+
} else {
|
|
74479
|
+
providerTools = request.registration.createTools({
|
|
74480
|
+
connectionId: resolution.connectionId,
|
|
74481
|
+
client: options.client,
|
|
74482
|
+
...providerFilterOptions(request.options)
|
|
74483
|
+
});
|
|
74484
|
+
applyProxyRequireApproval(providerTools, integrationId, request.options.requireApproval);
|
|
74485
|
+
}
|
|
74451
74486
|
else if (request.registration.transport === "mcp") {
|
|
74452
74487
|
for (const connection of resolution.connections) activeMcpKeys.add(`${integrationId}::${connection.id}`);
|
|
74453
74488
|
providerTools = await buildMcpMultiConnectionTools({
|
|
@@ -74455,19 +74490,23 @@ async function mapTools(connections, requests, options, client, mcpClients, reso
|
|
|
74455
74490
|
connections: resolution.connections,
|
|
74456
74491
|
allowTools: request.options.allowTools,
|
|
74457
74492
|
disallowTools: request.options.disallowTools,
|
|
74458
|
-
|
|
74493
|
+
requireApproval: request.options.requireApproval,
|
|
74459
74494
|
client,
|
|
74460
74495
|
mcpClients,
|
|
74461
74496
|
resolverId
|
|
74462
74497
|
});
|
|
74463
|
-
} else
|
|
74464
|
-
|
|
74465
|
-
|
|
74466
|
-
|
|
74467
|
-
|
|
74468
|
-
|
|
74469
|
-
|
|
74498
|
+
} else {
|
|
74499
|
+
providerTools = buildProxyMultiConnectionTools({
|
|
74500
|
+
registration: request.registration,
|
|
74501
|
+
connections: resolution.connections,
|
|
74502
|
+
allowTools: request.options.allowTools,
|
|
74503
|
+
disallowTools: request.options.disallowTools,
|
|
74504
|
+
client: options.client
|
|
74505
|
+
});
|
|
74506
|
+
applyProxyRequireApproval(providerTools, integrationId, request.options.requireApproval, [listConnectionsToolKey(integrationId)]);
|
|
74507
|
+
}
|
|
74470
74508
|
} catch (error) {
|
|
74509
|
+
if (error instanceof MastraConnectConfigError) throw error;
|
|
74471
74510
|
console.warn(`[@mastra/connect] Skipping ${integrationId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
74472
74511
|
continue;
|
|
74473
74512
|
}
|
|
@@ -74491,9 +74530,33 @@ async function mapTools(connections, requests, options, client, mcpClients, reso
|
|
|
74491
74530
|
function providerFilterOptions(options) {
|
|
74492
74531
|
return options.allowTools !== void 0 ? { allowTools: options.allowTools } : options.disallowTools !== void 0 ? { disallowTools: options.disallowTools } : {};
|
|
74493
74532
|
}
|
|
74533
|
+
/**
|
|
74534
|
+
* Applies a per-provider `requireApproval` policy to a checked-in HTTP
|
|
74535
|
+
* toolset by marking the selected tools. `true` gates every provider tool
|
|
74536
|
+
* (but never the synthetic `<provider>__list_connections` wrapper tool,
|
|
74537
|
+
* matching the MCP paths, where only server-discovered tools are gated);
|
|
74538
|
+
* an array gates the listed keys and rejects unknown names with the same
|
|
74539
|
+
* `invalid_options` error MCP discovery raises, so a typo never silently
|
|
74540
|
+
* widens access.
|
|
74541
|
+
*/
|
|
74542
|
+
function applyProxyRequireApproval(providerTools, integrationId, requireApproval, excludeKeys = []) {
|
|
74543
|
+
if (!requireApproval) return;
|
|
74544
|
+
if (requireApproval === true) {
|
|
74545
|
+
const excluded = new Set(excludeKeys);
|
|
74546
|
+
for (const [toolKey, tool] of Object.entries(providerTools)) {
|
|
74547
|
+
if (excluded.has(toolKey)) continue;
|
|
74548
|
+
tool.requireApproval = true;
|
|
74549
|
+
}
|
|
74550
|
+
return;
|
|
74551
|
+
}
|
|
74552
|
+
const known = Object.keys(providerTools);
|
|
74553
|
+
const unknown = requireApproval.filter((name) => !known.includes(name));
|
|
74554
|
+
if (unknown.length > 0) throw new MastraConnectConfigError(`Unknown tool name(s) in requireApproval for '${integrationId}': ${unknown.join(", ")}. Known tools: ${known.join(", ")}.`);
|
|
74555
|
+
for (const name of requireApproval) providerTools[name].requireApproval = true;
|
|
74556
|
+
}
|
|
74494
74557
|
async function discoverMcpTools(input) {
|
|
74495
|
-
const { registration, connectionId, allowTools, disallowTools,
|
|
74496
|
-
const
|
|
74558
|
+
const { registration, connectionId, allowTools, disallowTools, requireApproval, client, mcpClients, resolverId } = input;
|
|
74559
|
+
const requireApprovalFor = Array.isArray(requireApproval) ? new Set(requireApproval) : void 0;
|
|
74497
74560
|
const cacheKey = `${registration.integrationId}::${connectionId}`;
|
|
74498
74561
|
let entry = mcpClients.get(cacheKey);
|
|
74499
74562
|
if (!entry) {
|
|
@@ -74505,7 +74568,7 @@ async function discoverMcpTools(input) {
|
|
|
74505
74568
|
id: `mastra-connect-${resolverId}-${registration.integrationId}-${connectionId}`,
|
|
74506
74569
|
servers: { [registration.integrationId]: {
|
|
74507
74570
|
...transport,
|
|
74508
|
-
requireToolApproval: ({ toolName }) =>
|
|
74571
|
+
...requireApproval === true ? { requireToolApproval: true } : requireApprovalFor ? { requireToolApproval: ({ toolName }) => requireApprovalFor.has(`${registration.integrationId}_${String(toolName)}`) } : {}
|
|
74509
74572
|
} }
|
|
74510
74573
|
})
|
|
74511
74574
|
};
|
|
@@ -74514,8 +74577,10 @@ async function discoverMcpTools(input) {
|
|
|
74514
74577
|
const discovery = await entry.client.listToolsWithErrors();
|
|
74515
74578
|
const error = discovery.errors[registration.integrationId];
|
|
74516
74579
|
if (error) throw new Error(`MCP tool discovery failed: ${error}`);
|
|
74517
|
-
|
|
74518
|
-
|
|
74580
|
+
if (requireApprovalFor) {
|
|
74581
|
+
const unknown = [...requireApprovalFor].filter((name) => !(name in discovery.tools));
|
|
74582
|
+
if (unknown.length > 0) throw new MastraConnectConfigError(`Unknown tool name(s) in requireApproval for '${registration.integrationId}': ${unknown.join(", ")}. Known tools: ${Object.keys(discovery.tools).join(", ")}.`);
|
|
74583
|
+
}
|
|
74519
74584
|
return applyToolFilter(discovery.tools, {
|
|
74520
74585
|
allowTools,
|
|
74521
74586
|
disallowTools
|
|
@@ -74617,6 +74682,7 @@ async function channels(options = {}) {
|
|
|
74617
74682
|
let cache;
|
|
74618
74683
|
let inflight;
|
|
74619
74684
|
let lastFailureAt;
|
|
74685
|
+
let warnedStaleSlackConnection = false;
|
|
74620
74686
|
const buildSnapshot = async () => {
|
|
74621
74687
|
let connections;
|
|
74622
74688
|
try {
|
|
@@ -74627,6 +74693,10 @@ async function channels(options = {}) {
|
|
|
74627
74693
|
}
|
|
74628
74694
|
const byIntegrationId = groupByIntegrationId(connections);
|
|
74629
74695
|
const providers = {};
|
|
74696
|
+
if (!warnedStaleSlackConnection && states.some((state) => state.registration.integrationId === "slack-channels") && (byIntegrationId.get("slack")?.length ?? 0) > 0 && (byIntegrationId.get("slack-channels")?.length ?? 0) === 0) {
|
|
74697
|
+
warnedStaleSlackConnection = true;
|
|
74698
|
+
console.warn(`[@mastra/connect] Project ${projectId} has an active 'slack' connection but no 'slack-channels' connection: the Slack channel is now keyed off 'slack-channels'. Connect Slack again as 'slack-channels' to restore it; the existing 'slack' connection still powers the generated Slack tools.`);
|
|
74699
|
+
}
|
|
74630
74700
|
for (const state of states) {
|
|
74631
74701
|
const integrationId = state.registration.integrationId;
|
|
74632
74702
|
const overrides = options.integrations?.[integrationId] ?? {};
|
|
@@ -74738,7 +74808,9 @@ async function credential(connectionId, options) {
|
|
|
74738
74808
|
//#endregion
|
|
74739
74809
|
//#region src/environment.ts
|
|
74740
74810
|
function credentialToken(credential) {
|
|
74741
|
-
|
|
74811
|
+
if (credential.type === "oauth2") return credential.accessToken;
|
|
74812
|
+
if (credential.type === "two_step") return credential.token;
|
|
74813
|
+
return credential.apiKey;
|
|
74742
74814
|
}
|
|
74743
74815
|
/**
|
|
74744
74816
|
* Wires git's credential helper to read the token from the environment at use
|