@mastra/connect 0.7.0-alpha.1 → 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 +391 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +391 -201
- 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/tools/list-channels.d.ts +2 -2
- package/dist/providers/discord/tools/list-channels.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
|
};
|
|
@@ -797,17 +882,42 @@ const CHANNELS$1 = [
|
|
|
797
882
|
}
|
|
798
883
|
};
|
|
799
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
|
+
}
|
|
800
904
|
}
|
|
801
905
|
];
|
|
802
906
|
//#endregion
|
|
803
907
|
//#region src/runtime/platform-proxy.ts
|
|
804
908
|
/** Maps the platform credential to the field names templates are written against. */
|
|
805
909
|
function toTemplateCredentials(credential) {
|
|
806
|
-
|
|
910
|
+
if (credential.type === "oauth2") return {
|
|
807
911
|
type: "OAUTH2",
|
|
808
912
|
access_token: credential.accessToken,
|
|
809
913
|
expires_at: credential.expiresAt
|
|
810
|
-
}
|
|
914
|
+
};
|
|
915
|
+
if (credential.type === "two_step") return {
|
|
916
|
+
type: "TWO_STEP",
|
|
917
|
+
token: credential.token,
|
|
918
|
+
expires_at: credential.expiresAt
|
|
919
|
+
};
|
|
920
|
+
return {
|
|
811
921
|
type: "API_KEY",
|
|
812
922
|
apiKey: credential.apiKey
|
|
813
923
|
};
|
|
@@ -1735,8 +1845,8 @@ const anthropicProvider = {
|
|
|
1735
1845
|
//#endregion
|
|
1736
1846
|
//#region src/providers/clerk/tools/assign-organization-role-permission.ts
|
|
1737
1847
|
const assignOrganizationRolePermissionInputSchema = zod.z.object({
|
|
1738
|
-
organization_role_id: zod.z.string(),
|
|
1739
|
-
permission_id: zod.z.string()
|
|
1848
|
+
organization_role_id: zod.z.string().min(1),
|
|
1849
|
+
permission_id: zod.z.string().min(1)
|
|
1740
1850
|
});
|
|
1741
1851
|
const ResourceSchema$49 = zod.z.object({
|
|
1742
1852
|
id: zod.z.string(),
|
|
@@ -1772,8 +1882,8 @@ function assignOrganizationRolePermissionTool(proxy) {
|
|
|
1772
1882
|
//#endregion
|
|
1773
1883
|
//#region src/providers/clerk/tools/create-email-address.ts
|
|
1774
1884
|
const createEmailAddressInputSchema = zod.z.object({
|
|
1775
|
-
user_id: zod.z.string(),
|
|
1776
|
-
email_address: zod.z.string(),
|
|
1885
|
+
user_id: zod.z.string().min(1),
|
|
1886
|
+
email_address: zod.z.string().email(),
|
|
1777
1887
|
verified: zod.z.boolean().optional(),
|
|
1778
1888
|
primary: zod.z.boolean().optional(),
|
|
1779
1889
|
notify_primary_email_address_changed: zod.z.boolean().optional()
|
|
@@ -1818,16 +1928,22 @@ function createEmailAddressTool(proxy) {
|
|
|
1818
1928
|
}
|
|
1819
1929
|
//#endregion
|
|
1820
1930
|
//#region src/providers/clerk/tools/create-organization-domain.ts
|
|
1821
|
-
const EnrollmentModeSchema$
|
|
1931
|
+
const EnrollmentModeSchema$3 = zod.z.enum([
|
|
1822
1932
|
"manual_invitation",
|
|
1823
1933
|
"automatic_invitation",
|
|
1824
1934
|
"automatic_suggestion",
|
|
1825
1935
|
"enterprise_sso"
|
|
1826
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());
|
|
1827
1943
|
const createOrganizationDomainInputSchema$1 = zod.z.object({
|
|
1828
|
-
organization_id: zod.z.string(),
|
|
1944
|
+
organization_id: zod.z.string().min(1),
|
|
1829
1945
|
name: zod.z.string(),
|
|
1830
|
-
enrollment_mode: EnrollmentModeSchema$
|
|
1946
|
+
enrollment_mode: EnrollmentModeSchema$3,
|
|
1831
1947
|
verified: zod.z.boolean().optional()
|
|
1832
1948
|
});
|
|
1833
1949
|
const ResourceSchema$47 = zod.z.object({
|
|
@@ -1835,15 +1951,15 @@ const ResourceSchema$47 = zod.z.object({
|
|
|
1835
1951
|
object: zod.z.string().optional(),
|
|
1836
1952
|
organization_id: zod.z.string().optional(),
|
|
1837
1953
|
name: zod.z.string(),
|
|
1838
|
-
enrollment_mode:
|
|
1954
|
+
enrollment_mode: EnrollmentModeSchemaWidened$2.optional(),
|
|
1839
1955
|
affiliation_verification: zod.z.object({
|
|
1840
1956
|
attempts: zod.z.number().optional(),
|
|
1841
1957
|
status: zod.z.string().optional()
|
|
1842
|
-
}).passthrough().optional(),
|
|
1958
|
+
}).passthrough().nullable().optional(),
|
|
1843
1959
|
verification: zod.z.object({
|
|
1844
1960
|
attempts: zod.z.number().optional(),
|
|
1845
1961
|
status: zod.z.string().optional()
|
|
1846
|
-
}).passthrough().optional(),
|
|
1962
|
+
}).passthrough().nullable().optional(),
|
|
1847
1963
|
verified: zod.z.boolean().optional(),
|
|
1848
1964
|
created_at: zod.z.number().optional(),
|
|
1849
1965
|
updated_at: zod.z.number().optional()
|
|
@@ -1872,7 +1988,7 @@ function createOrganizationDomainTool$1(proxy) {
|
|
|
1872
1988
|
//#endregion
|
|
1873
1989
|
//#region src/providers/clerk/tools/create-organization-invitation.ts
|
|
1874
1990
|
const createOrganizationInvitationInputSchema = zod.z.object({
|
|
1875
|
-
organization_id: zod.z.string(),
|
|
1991
|
+
organization_id: zod.z.string().min(1),
|
|
1876
1992
|
email_address: zod.z.string().email(),
|
|
1877
1993
|
role: zod.z.string(),
|
|
1878
1994
|
inviter_user_id: zod.z.string().optional(),
|
|
@@ -1893,7 +2009,7 @@ const ResourceSchema$46 = zod.z.object({
|
|
|
1893
2009
|
"accepted",
|
|
1894
2010
|
"revoked",
|
|
1895
2011
|
"expired"
|
|
1896
|
-
]).optional(),
|
|
2012
|
+
]).or(zod.z.string()).optional(),
|
|
1897
2013
|
created_at: zod.z.number().optional(),
|
|
1898
2014
|
updated_at: zod.z.number().optional()
|
|
1899
2015
|
}).passthrough();
|
|
@@ -1926,8 +2042,8 @@ function createOrganizationInvitationTool(proxy) {
|
|
|
1926
2042
|
//#endregion
|
|
1927
2043
|
//#region src/providers/clerk/tools/create-organization-membership.ts
|
|
1928
2044
|
const createOrganizationMembershipInputSchema$1 = zod.z.object({
|
|
1929
|
-
organization_id: zod.z.string(),
|
|
1930
|
-
user_id: zod.z.string(),
|
|
2045
|
+
organization_id: zod.z.string().min(1),
|
|
2046
|
+
user_id: zod.z.string().min(1),
|
|
1931
2047
|
role: zod.z.string(),
|
|
1932
2048
|
public_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
1933
2049
|
private_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
@@ -2063,7 +2179,7 @@ function createOrganizationTool$1(proxy) {
|
|
|
2063
2179
|
//#endregion
|
|
2064
2180
|
//#region src/providers/clerk/tools/create-phone-number.ts
|
|
2065
2181
|
const createPhoneNumberInputSchema = zod.z.object({
|
|
2066
|
-
user_id: zod.z.string(),
|
|
2182
|
+
user_id: zod.z.string().min(1),
|
|
2067
2183
|
phone_number: zod.z.string(),
|
|
2068
2184
|
verified: zod.z.boolean().optional(),
|
|
2069
2185
|
primary: zod.z.boolean().optional(),
|
|
@@ -2126,7 +2242,7 @@ const createUserInputSchema$2 = zod.z.object({
|
|
|
2126
2242
|
public_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
2127
2243
|
private_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
2128
2244
|
unsafe_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
2129
|
-
});
|
|
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." });
|
|
2130
2246
|
const UserSchema$27 = zod.z.object({
|
|
2131
2247
|
id: zod.z.string(),
|
|
2132
2248
|
object: zod.z.string().optional(),
|
|
@@ -2178,7 +2294,7 @@ function createUserTool$2(proxy) {
|
|
|
2178
2294
|
}
|
|
2179
2295
|
//#endregion
|
|
2180
2296
|
//#region src/providers/clerk/tools/delete-email-address.ts
|
|
2181
|
-
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) });
|
|
2182
2298
|
const deleteEmailAddressOutputSchema = zod.z.object({
|
|
2183
2299
|
id: zod.z.string(),
|
|
2184
2300
|
success: zod.z.boolean()
|
|
@@ -2204,8 +2320,8 @@ function deleteEmailAddressTool(proxy) {
|
|
|
2204
2320
|
//#endregion
|
|
2205
2321
|
//#region src/providers/clerk/tools/delete-organization-domain.ts
|
|
2206
2322
|
const deleteOrganizationDomainInputSchema$1 = zod.z.object({
|
|
2207
|
-
organization_id: zod.z.string(),
|
|
2208
|
-
domain_id: zod.z.string()
|
|
2323
|
+
organization_id: zod.z.string().min(1),
|
|
2324
|
+
domain_id: zod.z.string().min(1)
|
|
2209
2325
|
});
|
|
2210
2326
|
const deleteOrganizationDomainOutputSchema$1 = zod.z.object({
|
|
2211
2327
|
id: zod.z.string(),
|
|
@@ -2232,8 +2348,8 @@ function deleteOrganizationDomainTool$1(proxy) {
|
|
|
2232
2348
|
//#endregion
|
|
2233
2349
|
//#region src/providers/clerk/tools/delete-organization-membership.ts
|
|
2234
2350
|
const deleteOrganizationMembershipInputSchema$1 = zod.z.object({
|
|
2235
|
-
organization_id: zod.z.string(),
|
|
2236
|
-
user_id: zod.z.string()
|
|
2351
|
+
organization_id: zod.z.string().min(1),
|
|
2352
|
+
user_id: zod.z.string().min(1)
|
|
2237
2353
|
});
|
|
2238
2354
|
const deleteOrganizationMembershipOutputSchema$1 = zod.z.object({
|
|
2239
2355
|
id: zod.z.string(),
|
|
@@ -2259,7 +2375,7 @@ function deleteOrganizationMembershipTool$1(proxy) {
|
|
|
2259
2375
|
}
|
|
2260
2376
|
//#endregion
|
|
2261
2377
|
//#region src/providers/clerk/tools/delete-organization-role.ts
|
|
2262
|
-
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) });
|
|
2263
2379
|
const deleteOrganizationRoleOutputSchema = zod.z.object({
|
|
2264
2380
|
id: zod.z.string(),
|
|
2265
2381
|
success: zod.z.boolean()
|
|
@@ -2309,7 +2425,7 @@ function deleteOrganizationTool$1(proxy) {
|
|
|
2309
2425
|
}
|
|
2310
2426
|
//#endregion
|
|
2311
2427
|
//#region src/providers/clerk/tools/delete-phone-number.ts
|
|
2312
|
-
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) });
|
|
2313
2429
|
const deletePhoneNumberOutputSchema = zod.z.object({
|
|
2314
2430
|
id: zod.z.string(),
|
|
2315
2431
|
success: zod.z.boolean()
|
|
@@ -2359,7 +2475,7 @@ function deleteUserTool$2(proxy) {
|
|
|
2359
2475
|
}
|
|
2360
2476
|
//#endregion
|
|
2361
2477
|
//#region src/providers/clerk/tools/get-email-address.ts
|
|
2362
|
-
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) });
|
|
2363
2479
|
const ResourceSchema$42 = zod.z.object({
|
|
2364
2480
|
id: zod.z.string(),
|
|
2365
2481
|
object: zod.z.string().optional(),
|
|
@@ -2394,8 +2510,8 @@ function getEmailAddressTool(proxy) {
|
|
|
2394
2510
|
//#endregion
|
|
2395
2511
|
//#region src/providers/clerk/tools/get-organization-invitation.ts
|
|
2396
2512
|
const getOrganizationInvitationInputSchema = zod.z.object({
|
|
2397
|
-
organization_id: zod.z.string(),
|
|
2398
|
-
invitation_id: zod.z.string()
|
|
2513
|
+
organization_id: zod.z.string().min(1),
|
|
2514
|
+
invitation_id: zod.z.string().min(1)
|
|
2399
2515
|
});
|
|
2400
2516
|
const ResourceSchema$41 = zod.z.object({
|
|
2401
2517
|
id: zod.z.string(),
|
|
@@ -2408,7 +2524,7 @@ const ResourceSchema$41 = zod.z.object({
|
|
|
2408
2524
|
"accepted",
|
|
2409
2525
|
"revoked",
|
|
2410
2526
|
"expired"
|
|
2411
|
-
]).optional(),
|
|
2527
|
+
]).or(zod.z.string()).optional(),
|
|
2412
2528
|
created_at: zod.z.number().optional(),
|
|
2413
2529
|
updated_at: zod.z.number().optional()
|
|
2414
2530
|
}).passthrough();
|
|
@@ -2430,7 +2546,7 @@ function getOrganizationInvitationTool(proxy) {
|
|
|
2430
2546
|
}
|
|
2431
2547
|
//#endregion
|
|
2432
2548
|
//#region src/providers/clerk/tools/get-organization-role.ts
|
|
2433
|
-
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) });
|
|
2434
2550
|
const ResourceSchema$40 = zod.z.object({
|
|
2435
2551
|
id: zod.z.string(),
|
|
2436
2552
|
object: zod.z.string().optional(),
|
|
@@ -2502,7 +2618,7 @@ function getOrganizationTool$1(proxy) {
|
|
|
2502
2618
|
}
|
|
2503
2619
|
//#endregion
|
|
2504
2620
|
//#region src/providers/clerk/tools/get-phone-number.ts
|
|
2505
|
-
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) });
|
|
2506
2622
|
const ResourceSchema$39 = zod.z.object({
|
|
2507
2623
|
id: zod.z.string(),
|
|
2508
2624
|
object: zod.z.string().optional(),
|
|
@@ -2537,7 +2653,7 @@ function getPhoneNumberTool(proxy) {
|
|
|
2537
2653
|
}
|
|
2538
2654
|
//#endregion
|
|
2539
2655
|
//#region src/providers/clerk/tools/get-session.ts
|
|
2540
|
-
const getSessionInputSchema = zod.z.object({ session_id: zod.z.string() });
|
|
2656
|
+
const getSessionInputSchema = zod.z.object({ session_id: zod.z.string().min(1) });
|
|
2541
2657
|
const ResourceSchema$38 = zod.z.object({
|
|
2542
2658
|
id: zod.z.string(),
|
|
2543
2659
|
object: zod.z.string().optional(),
|
|
@@ -2551,7 +2667,7 @@ const ResourceSchema$38 = zod.z.object({
|
|
|
2551
2667
|
"removed",
|
|
2552
2668
|
"replaced",
|
|
2553
2669
|
"revoked"
|
|
2554
|
-
]).optional(),
|
|
2670
|
+
]).or(zod.z.string()).optional(),
|
|
2555
2671
|
last_active_at: zod.z.number().optional(),
|
|
2556
2672
|
expire_at: zod.z.number().optional(),
|
|
2557
2673
|
abandon_at: zod.z.number().optional(),
|
|
@@ -2611,33 +2727,39 @@ function getUserTool$7(proxy) {
|
|
|
2611
2727
|
}
|
|
2612
2728
|
//#endregion
|
|
2613
2729
|
//#region src/providers/clerk/tools/list-organization-domains.ts
|
|
2614
|
-
const EnrollmentModeSchema$
|
|
2730
|
+
const EnrollmentModeSchema$2 = zod.z.enum([
|
|
2615
2731
|
"manual_invitation",
|
|
2616
2732
|
"automatic_invitation",
|
|
2617
2733
|
"automatic_suggestion",
|
|
2618
2734
|
"enterprise_sso"
|
|
2619
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());
|
|
2620
2742
|
const listOrganizationDomainsInputSchema = zod.z.object({
|
|
2621
|
-
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."),
|
|
2622
2744
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2623
|
-
organization_id: zod.z.string(),
|
|
2745
|
+
organization_id: zod.z.string().min(1),
|
|
2624
2746
|
verified: zod.z.boolean().optional(),
|
|
2625
|
-
enrollment_mode: EnrollmentModeSchema$
|
|
2747
|
+
enrollment_mode: EnrollmentModeSchema$2.optional()
|
|
2626
2748
|
});
|
|
2627
2749
|
const ResourceSchema$37 = zod.z.object({
|
|
2628
2750
|
id: zod.z.string(),
|
|
2629
2751
|
object: zod.z.string().optional(),
|
|
2630
2752
|
organization_id: zod.z.string().optional(),
|
|
2631
2753
|
name: zod.z.string(),
|
|
2632
|
-
enrollment_mode:
|
|
2754
|
+
enrollment_mode: EnrollmentModeSchemaWidened$1.optional(),
|
|
2633
2755
|
affiliation_verification: zod.z.object({
|
|
2634
2756
|
attempts: zod.z.number().optional(),
|
|
2635
2757
|
status: zod.z.string().optional()
|
|
2636
|
-
}).passthrough().optional(),
|
|
2758
|
+
}).passthrough().nullable().optional(),
|
|
2637
2759
|
verification: zod.z.object({
|
|
2638
2760
|
attempts: zod.z.number().optional(),
|
|
2639
2761
|
status: zod.z.string().optional()
|
|
2640
|
-
}).passthrough().optional(),
|
|
2762
|
+
}).passthrough().nullable().optional(),
|
|
2641
2763
|
verified: zod.z.boolean().optional(),
|
|
2642
2764
|
created_at: zod.z.number().optional(),
|
|
2643
2765
|
updated_at: zod.z.number().optional()
|
|
@@ -2648,7 +2770,7 @@ const ProviderResponseSchema$244 = zod.z.object({
|
|
|
2648
2770
|
});
|
|
2649
2771
|
const listOrganizationDomainsOutputSchema = zod.z.object({
|
|
2650
2772
|
items: zod.z.array(ResourceSchema$37),
|
|
2651
|
-
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."),
|
|
2652
2774
|
total: zod.z.number()
|
|
2653
2775
|
});
|
|
2654
2776
|
function listOrganizationDomainsTool(proxy) {
|
|
@@ -2659,11 +2781,7 @@ function listOrganizationDomainsTool(proxy) {
|
|
|
2659
2781
|
outputSchema: listOrganizationDomainsOutputSchema,
|
|
2660
2782
|
execute: async (input, { requestContext }) => {
|
|
2661
2783
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2662
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2663
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2664
|
-
type: "invalid_cursor",
|
|
2665
|
-
message: "Cursor must be a non-negative integer."
|
|
2666
|
-
});
|
|
2784
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2667
2785
|
const response = await platformProxy.get({
|
|
2668
2786
|
endpoint: `/v1/organizations/${encodeURIComponent(input.organization_id)}/domains`,
|
|
2669
2787
|
params: {
|
|
@@ -2687,9 +2805,9 @@ function listOrganizationDomainsTool(proxy) {
|
|
|
2687
2805
|
//#endregion
|
|
2688
2806
|
//#region src/providers/clerk/tools/list-organization-invitations.ts
|
|
2689
2807
|
const listOrganizationInvitationsInputSchema = zod.z.object({
|
|
2690
|
-
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."),
|
|
2691
2809
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2692
|
-
organization_id: zod.z.string(),
|
|
2810
|
+
organization_id: zod.z.string().min(1),
|
|
2693
2811
|
status: zod.z.enum([
|
|
2694
2812
|
"pending",
|
|
2695
2813
|
"accepted",
|
|
@@ -2710,7 +2828,7 @@ const ResourceSchema$36 = zod.z.object({
|
|
|
2710
2828
|
"accepted",
|
|
2711
2829
|
"revoked",
|
|
2712
2830
|
"expired"
|
|
2713
|
-
]).optional(),
|
|
2831
|
+
]).or(zod.z.string()).optional(),
|
|
2714
2832
|
created_at: zod.z.number().optional(),
|
|
2715
2833
|
updated_at: zod.z.number().optional()
|
|
2716
2834
|
}).passthrough();
|
|
@@ -2720,7 +2838,7 @@ const ProviderResponseSchema$243 = zod.z.object({
|
|
|
2720
2838
|
});
|
|
2721
2839
|
const listOrganizationInvitationsOutputSchema = zod.z.object({
|
|
2722
2840
|
items: zod.z.array(ResourceSchema$36),
|
|
2723
|
-
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."),
|
|
2724
2842
|
total: zod.z.number()
|
|
2725
2843
|
});
|
|
2726
2844
|
function listOrganizationInvitationsTool(proxy) {
|
|
@@ -2731,11 +2849,7 @@ function listOrganizationInvitationsTool(proxy) {
|
|
|
2731
2849
|
outputSchema: listOrganizationInvitationsOutputSchema,
|
|
2732
2850
|
execute: async (input, { requestContext }) => {
|
|
2733
2851
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2734
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2735
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2736
|
-
type: "invalid_cursor",
|
|
2737
|
-
message: "Cursor must be a non-negative integer."
|
|
2738
|
-
});
|
|
2852
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2739
2853
|
const response = await platformProxy.get({
|
|
2740
2854
|
endpoint: `/v1/organizations/${encodeURIComponent(input.organization_id)}/invitations`,
|
|
2741
2855
|
params: {
|
|
@@ -2760,9 +2874,9 @@ function listOrganizationInvitationsTool(proxy) {
|
|
|
2760
2874
|
//#endregion
|
|
2761
2875
|
//#region src/providers/clerk/tools/list-organization-memberships.ts
|
|
2762
2876
|
const listOrganizationMembershipsInputSchema$1 = zod.z.object({
|
|
2763
|
-
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."),
|
|
2764
2878
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2765
|
-
organization_id: zod.z.string(),
|
|
2879
|
+
organization_id: zod.z.string().min(1),
|
|
2766
2880
|
user_id: zod.z.array(zod.z.string()).optional(),
|
|
2767
2881
|
email_address: zod.z.array(zod.z.string()).optional(),
|
|
2768
2882
|
phone_number: zod.z.array(zod.z.string()).optional(),
|
|
@@ -2796,7 +2910,7 @@ const ProviderResponseSchema$242 = zod.z.object({
|
|
|
2796
2910
|
});
|
|
2797
2911
|
const listOrganizationMembershipsOutputSchema$1 = zod.z.object({
|
|
2798
2912
|
items: zod.z.array(ResourceSchema$35),
|
|
2799
|
-
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."),
|
|
2800
2914
|
total: zod.z.number()
|
|
2801
2915
|
});
|
|
2802
2916
|
function listOrganizationMembershipsTool$1(proxy) {
|
|
@@ -2807,11 +2921,7 @@ function listOrganizationMembershipsTool$1(proxy) {
|
|
|
2807
2921
|
outputSchema: listOrganizationMembershipsOutputSchema$1,
|
|
2808
2922
|
execute: async (input, { requestContext }) => {
|
|
2809
2923
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2810
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2811
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2812
|
-
type: "invalid_cursor",
|
|
2813
|
-
message: "Cursor must be a non-negative integer."
|
|
2814
|
-
});
|
|
2924
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2815
2925
|
const response = await platformProxy.get({
|
|
2816
2926
|
endpoint: `/v1/organizations/${encodeURIComponent(input.organization_id)}/memberships`,
|
|
2817
2927
|
params: {
|
|
@@ -2849,7 +2959,7 @@ function listOrganizationMembershipsTool$1(proxy) {
|
|
|
2849
2959
|
//#endregion
|
|
2850
2960
|
//#region src/providers/clerk/tools/list-organization-roles.ts
|
|
2851
2961
|
const listOrganizationRolesInputSchema = zod.z.object({
|
|
2852
|
-
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."),
|
|
2853
2963
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2854
2964
|
query: zod.z.string().optional(),
|
|
2855
2965
|
order_by: zod.z.string().optional()
|
|
@@ -2874,7 +2984,7 @@ const ProviderResponseSchema$241 = zod.z.object({
|
|
|
2874
2984
|
});
|
|
2875
2985
|
const listOrganizationRolesOutputSchema = zod.z.object({
|
|
2876
2986
|
items: zod.z.array(ResourceSchema$34),
|
|
2877
|
-
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."),
|
|
2878
2988
|
total: zod.z.number()
|
|
2879
2989
|
});
|
|
2880
2990
|
function listOrganizationRolesTool(proxy) {
|
|
@@ -2885,11 +2995,7 @@ function listOrganizationRolesTool(proxy) {
|
|
|
2885
2995
|
outputSchema: listOrganizationRolesOutputSchema,
|
|
2886
2996
|
execute: async (input, { requestContext }) => {
|
|
2887
2997
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2888
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2889
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2890
|
-
type: "invalid_cursor",
|
|
2891
|
-
message: "Cursor must be a non-negative integer."
|
|
2892
|
-
});
|
|
2998
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2893
2999
|
const response = await platformProxy.get({
|
|
2894
3000
|
endpoint: "/v1/organization_roles",
|
|
2895
3001
|
params: {
|
|
@@ -2913,7 +3019,7 @@ function listOrganizationRolesTool(proxy) {
|
|
|
2913
3019
|
//#endregion
|
|
2914
3020
|
//#region src/providers/clerk/tools/list-organizations.ts
|
|
2915
3021
|
const listOrganizationsInputSchema$1 = zod.z.object({
|
|
2916
|
-
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."),
|
|
2917
3023
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2918
3024
|
query: zod.z.string().optional(),
|
|
2919
3025
|
order_by: zod.z.string().optional().describe("Sort by name, created_at, or members_count, prefixed with + or -."),
|
|
@@ -2953,11 +3059,7 @@ function listOrganizationsTool$1(proxy) {
|
|
|
2953
3059
|
outputSchema: listOrganizationsOutputSchema$1,
|
|
2954
3060
|
execute: async (input, { requestContext }) => {
|
|
2955
3061
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
2956
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
2957
|
-
if (!Number.isInteger(offset) || offset < 0) throw new platformProxy.ActionError({
|
|
2958
|
-
type: "invalid_cursor",
|
|
2959
|
-
message: "Cursor must be a non-negative integer."
|
|
2960
|
-
});
|
|
3062
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
2961
3063
|
const response = await platformProxy.get({
|
|
2962
3064
|
endpoint: "/v1/organizations",
|
|
2963
3065
|
params: {
|
|
@@ -2983,10 +3085,10 @@ function listOrganizationsTool$1(proxy) {
|
|
|
2983
3085
|
//#endregion
|
|
2984
3086
|
//#region src/providers/clerk/tools/list-sessions.ts
|
|
2985
3087
|
const listSessionsInputSchema = zod.z.object({
|
|
2986
|
-
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."),
|
|
2987
3089
|
limit: zod.z.number().int().min(1).max(500).optional(),
|
|
2988
|
-
client_id: zod.z.string().optional(),
|
|
2989
|
-
user_id: zod.z.string().optional(),
|
|
3090
|
+
client_id: zod.z.string().min(1).optional(),
|
|
3091
|
+
user_id: zod.z.string().min(1).optional(),
|
|
2990
3092
|
status: zod.z.enum([
|
|
2991
3093
|
"abandoned",
|
|
2992
3094
|
"active",
|
|
@@ -2996,7 +3098,7 @@ const listSessionsInputSchema = zod.z.object({
|
|
|
2996
3098
|
"replaced",
|
|
2997
3099
|
"revoked"
|
|
2998
3100
|
]).optional()
|
|
2999
|
-
});
|
|
3101
|
+
}).refine((value) => value.client_id !== void 0 || value.user_id !== void 0, { message: "Provide at least one of client_id or user_id." });
|
|
3000
3102
|
const ResourceSchema$33 = zod.z.object({
|
|
3001
3103
|
id: zod.z.string(),
|
|
3002
3104
|
object: zod.z.string().optional(),
|
|
@@ -3010,21 +3112,17 @@ const ResourceSchema$33 = zod.z.object({
|
|
|
3010
3112
|
"removed",
|
|
3011
3113
|
"replaced",
|
|
3012
3114
|
"revoked"
|
|
3013
|
-
]).optional(),
|
|
3115
|
+
]).or(zod.z.string()).optional(),
|
|
3014
3116
|
last_active_at: zod.z.number().optional(),
|
|
3015
3117
|
expire_at: zod.z.number().optional(),
|
|
3016
3118
|
abandon_at: zod.z.number().optional(),
|
|
3017
3119
|
created_at: zod.z.number().optional(),
|
|
3018
3120
|
updated_at: zod.z.number().optional()
|
|
3019
3121
|
}).passthrough();
|
|
3020
|
-
const ProviderResponseSchema$239 = zod.z.
|
|
3021
|
-
data: zod.z.array(ResourceSchema$33),
|
|
3022
|
-
total_count: zod.z.number()
|
|
3023
|
-
});
|
|
3122
|
+
const ProviderResponseSchema$239 = zod.z.array(ResourceSchema$33);
|
|
3024
3123
|
const listSessionsOutputSchema = zod.z.object({
|
|
3025
3124
|
items: zod.z.array(ResourceSchema$33),
|
|
3026
|
-
next_cursor: zod.z.string().optional()
|
|
3027
|
-
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.")
|
|
3028
3126
|
});
|
|
3029
3127
|
function listSessionsTool(proxy) {
|
|
3030
3128
|
return (0, _mastra_core_tools.createTool)({
|
|
@@ -3034,28 +3132,23 @@ function listSessionsTool(proxy) {
|
|
|
3034
3132
|
outputSchema: listSessionsOutputSchema,
|
|
3035
3133
|
execute: async (input, { requestContext }) => {
|
|
3036
3134
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
3037
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
3038
|
-
|
|
3039
|
-
type: "invalid_cursor",
|
|
3040
|
-
message: "Cursor must be a non-negative integer."
|
|
3041
|
-
});
|
|
3135
|
+
const offset = input.cursor === void 0 ? 0 : Number(input.cursor);
|
|
3136
|
+
const limit = input.limit ?? 10;
|
|
3042
3137
|
const response = await platformProxy.get({
|
|
3043
3138
|
endpoint: "/v1/sessions",
|
|
3044
3139
|
params: {
|
|
3045
3140
|
offset: String(offset),
|
|
3046
|
-
|
|
3141
|
+
limit: String(limit),
|
|
3047
3142
|
...input.client_id !== void 0 && { client_id: input.client_id },
|
|
3048
3143
|
...input.user_id !== void 0 && { user_id: input.user_id },
|
|
3049
3144
|
...input.status !== void 0 && { status: input.status }
|
|
3050
3145
|
},
|
|
3051
3146
|
retries: 3
|
|
3052
3147
|
});
|
|
3053
|
-
const
|
|
3054
|
-
const nextOffset = offset + provider.data.length;
|
|
3148
|
+
const sessions = ProviderResponseSchema$239.parse(response.data);
|
|
3055
3149
|
return {
|
|
3056
|
-
items:
|
|
3057
|
-
...
|
|
3058
|
-
total: provider.total_count
|
|
3150
|
+
items: sessions,
|
|
3151
|
+
...sessions.length === limit && { next_cursor: String(offset + sessions.length) }
|
|
3059
3152
|
};
|
|
3060
3153
|
}
|
|
3061
3154
|
});
|
|
@@ -3063,13 +3156,19 @@ function listSessionsTool(proxy) {
|
|
|
3063
3156
|
//#endregion
|
|
3064
3157
|
//#region src/providers/clerk/tools/list-users.ts
|
|
3065
3158
|
const listUsersInputSchema$9 = zod.z.object({
|
|
3066
|
-
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."),
|
|
3067
3160
|
limit: zod.z.number().int().min(1).max(500).optional().describe("Maximum number of users to return. Maximum 500."),
|
|
3068
3161
|
query: zod.z.string().optional().describe("Search across names, identifiers, email addresses, phone numbers, and usernames."),
|
|
3069
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."),
|
|
3070
3165
|
user_id: zod.z.array(zod.z.string()).max(100).optional().describe("Filter by Clerk user IDs."),
|
|
3071
3166
|
external_id: zod.z.array(zod.z.string()).max(100).optional().describe("Filter by external user IDs."),
|
|
3072
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."),
|
|
3073
3172
|
order_by: zod.z.string().optional().describe("Sort field prefixed with + for ascending or - for descending. Example: \"-created_at\"")
|
|
3074
3173
|
});
|
|
3075
3174
|
const UserSchema$25 = zod.z.object({
|
|
@@ -3088,13 +3187,11 @@ const UserSchema$25 = zod.z.object({
|
|
|
3088
3187
|
updated_at: zod.z.number().optional(),
|
|
3089
3188
|
locale: zod.z.string().nullable().optional()
|
|
3090
3189
|
}).passthrough();
|
|
3091
|
-
const ProviderResponseSchema$238 = zod.z.
|
|
3092
|
-
|
|
3093
|
-
total_count: zod.z.number()
|
|
3094
|
-
});
|
|
3190
|
+
const ProviderResponseSchema$238 = zod.z.array(UserSchema$25);
|
|
3191
|
+
const ProviderCountSchema = zod.z.object({ total_count: zod.z.number() }).passthrough();
|
|
3095
3192
|
const listUsersOutputSchema$9 = zod.z.object({
|
|
3096
3193
|
items: zod.z.array(UserSchema$25),
|
|
3097
|
-
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."),
|
|
3098
3195
|
total: zod.z.number()
|
|
3099
3196
|
});
|
|
3100
3197
|
function listUsersTool$9(proxy) {
|
|
@@ -3105,31 +3202,42 @@ function listUsersTool$9(proxy) {
|
|
|
3105
3202
|
outputSchema: listUsersOutputSchema$9,
|
|
3106
3203
|
execute: async (input, { requestContext }) => {
|
|
3107
3204
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
3108
|
-
const offset = input.cursor === void 0 ? 0 : Number
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
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
|
+
};
|
|
3113
3219
|
const response = await platformProxy.get({
|
|
3114
3220
|
endpoint: "/v1/users",
|
|
3115
3221
|
params: {
|
|
3116
3222
|
offset: String(offset),
|
|
3117
3223
|
...input.limit !== void 0 && { limit: String(input.limit) },
|
|
3118
|
-
...input.
|
|
3119
|
-
...
|
|
3120
|
-
...input.user_id !== void 0 && { user_id: input.user_id },
|
|
3121
|
-
...input.external_id !== void 0 && { external_id: input.external_id },
|
|
3122
|
-
...input.organization_id !== void 0 && { organization_id: input.organization_id },
|
|
3123
|
-
...input.order_by !== void 0 && { order_by: input.order_by }
|
|
3224
|
+
...input.order_by !== void 0 && { order_by: input.order_by },
|
|
3225
|
+
...filterParams
|
|
3124
3226
|
},
|
|
3125
3227
|
retries: 3
|
|
3126
3228
|
});
|
|
3127
|
-
const
|
|
3128
|
-
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;
|
|
3129
3237
|
return {
|
|
3130
|
-
items:
|
|
3131
|
-
...nextOffset <
|
|
3132
|
-
total
|
|
3238
|
+
items: users,
|
|
3239
|
+
...users.length > 0 && nextOffset < total && { next_cursor: String(nextOffset) },
|
|
3240
|
+
total
|
|
3133
3241
|
};
|
|
3134
3242
|
}
|
|
3135
3243
|
});
|
|
@@ -3137,8 +3245,8 @@ function listUsersTool$9(proxy) {
|
|
|
3137
3245
|
//#endregion
|
|
3138
3246
|
//#region src/providers/clerk/tools/remove-organization-role-permission.ts
|
|
3139
3247
|
const removeOrganizationRolePermissionInputSchema = zod.z.object({
|
|
3140
|
-
organization_role_id: zod.z.string(),
|
|
3141
|
-
permission_id: zod.z.string()
|
|
3248
|
+
organization_role_id: zod.z.string().min(1),
|
|
3249
|
+
permission_id: zod.z.string().min(1)
|
|
3142
3250
|
});
|
|
3143
3251
|
const removeOrganizationRolePermissionOutputSchema = zod.z.object({
|
|
3144
3252
|
id: zod.z.string(),
|
|
@@ -3165,8 +3273,8 @@ function removeOrganizationRolePermissionTool(proxy) {
|
|
|
3165
3273
|
//#endregion
|
|
3166
3274
|
//#region src/providers/clerk/tools/revoke-organization-invitation.ts
|
|
3167
3275
|
const revokeOrganizationInvitationInputSchema = zod.z.object({
|
|
3168
|
-
organization_id: zod.z.string(),
|
|
3169
|
-
invitation_id: zod.z.string(),
|
|
3276
|
+
organization_id: zod.z.string().min(1),
|
|
3277
|
+
invitation_id: zod.z.string().min(1),
|
|
3170
3278
|
requesting_user_id: zod.z.string().optional()
|
|
3171
3279
|
});
|
|
3172
3280
|
const ResourceSchema$32 = zod.z.object({
|
|
@@ -3180,7 +3288,7 @@ const ResourceSchema$32 = zod.z.object({
|
|
|
3180
3288
|
"accepted",
|
|
3181
3289
|
"revoked",
|
|
3182
3290
|
"expired"
|
|
3183
|
-
]).optional(),
|
|
3291
|
+
]).or(zod.z.string()).optional(),
|
|
3184
3292
|
created_at: zod.z.number().optional(),
|
|
3185
3293
|
updated_at: zod.z.number().optional()
|
|
3186
3294
|
}).passthrough();
|
|
@@ -3203,7 +3311,7 @@ function revokeOrganizationInvitationTool(proxy) {
|
|
|
3203
3311
|
}
|
|
3204
3312
|
//#endregion
|
|
3205
3313
|
//#region src/providers/clerk/tools/revoke-session.ts
|
|
3206
|
-
const revokeSessionInputSchema = zod.z.object({ session_id: zod.z.string() });
|
|
3314
|
+
const revokeSessionInputSchema = zod.z.object({ session_id: zod.z.string().min(1) });
|
|
3207
3315
|
const ResourceSchema$31 = zod.z.object({
|
|
3208
3316
|
id: zod.z.string(),
|
|
3209
3317
|
object: zod.z.string().optional(),
|
|
@@ -3217,7 +3325,7 @@ const ResourceSchema$31 = zod.z.object({
|
|
|
3217
3325
|
"removed",
|
|
3218
3326
|
"replaced",
|
|
3219
3327
|
"revoked"
|
|
3220
|
-
]).optional(),
|
|
3328
|
+
]).or(zod.z.string()).optional(),
|
|
3221
3329
|
last_active_at: zod.z.number().optional(),
|
|
3222
3330
|
expire_at: zod.z.number().optional(),
|
|
3223
3331
|
abandon_at: zod.z.number().optional(),
|
|
@@ -3244,7 +3352,7 @@ function revokeSessionTool(proxy) {
|
|
|
3244
3352
|
//#endregion
|
|
3245
3353
|
//#region src/providers/clerk/tools/update-email-address.ts
|
|
3246
3354
|
const updateEmailAddressInputSchema = zod.z.object({
|
|
3247
|
-
email_address_id: zod.z.string(),
|
|
3355
|
+
email_address_id: zod.z.string().min(1),
|
|
3248
3356
|
verified: zod.z.boolean().optional(),
|
|
3249
3357
|
primary: zod.z.boolean().optional(),
|
|
3250
3358
|
notify_primary_email_address_changed: zod.z.boolean().optional()
|
|
@@ -3287,16 +3395,22 @@ function updateEmailAddressTool(proxy) {
|
|
|
3287
3395
|
}
|
|
3288
3396
|
//#endregion
|
|
3289
3397
|
//#region src/providers/clerk/tools/update-organization-domain.ts
|
|
3290
|
-
const EnrollmentModeSchema = zod.z.enum([
|
|
3398
|
+
const EnrollmentModeSchema$1 = zod.z.enum([
|
|
3291
3399
|
"manual_invitation",
|
|
3292
3400
|
"automatic_invitation",
|
|
3293
3401
|
"automatic_suggestion",
|
|
3294
3402
|
"enterprise_sso"
|
|
3295
3403
|
]);
|
|
3404
|
+
const EnrollmentModeSchemaWidened = zod.z.enum([
|
|
3405
|
+
"manual_invitation",
|
|
3406
|
+
"automatic_invitation",
|
|
3407
|
+
"automatic_suggestion",
|
|
3408
|
+
"enterprise_sso"
|
|
3409
|
+
]).or(zod.z.string());
|
|
3296
3410
|
const updateOrganizationDomainInputSchema = zod.z.object({
|
|
3297
|
-
organization_id: zod.z.string(),
|
|
3298
|
-
domain_id: zod.z.string(),
|
|
3299
|
-
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(),
|
|
3300
3414
|
verified: zod.z.boolean().optional()
|
|
3301
3415
|
});
|
|
3302
3416
|
const ResourceSchema$29 = zod.z.object({
|
|
@@ -3304,15 +3418,15 @@ const ResourceSchema$29 = zod.z.object({
|
|
|
3304
3418
|
object: zod.z.string().optional(),
|
|
3305
3419
|
organization_id: zod.z.string().optional(),
|
|
3306
3420
|
name: zod.z.string(),
|
|
3307
|
-
enrollment_mode:
|
|
3421
|
+
enrollment_mode: EnrollmentModeSchemaWidened.optional(),
|
|
3308
3422
|
affiliation_verification: zod.z.object({
|
|
3309
3423
|
attempts: zod.z.number().optional(),
|
|
3310
3424
|
status: zod.z.string().optional()
|
|
3311
|
-
}).passthrough().optional(),
|
|
3425
|
+
}).passthrough().nullable().optional(),
|
|
3312
3426
|
verification: zod.z.object({
|
|
3313
3427
|
attempts: zod.z.number().optional(),
|
|
3314
3428
|
status: zod.z.string().optional()
|
|
3315
|
-
}).passthrough().optional(),
|
|
3429
|
+
}).passthrough().nullable().optional(),
|
|
3316
3430
|
verified: zod.z.boolean().optional(),
|
|
3317
3431
|
created_at: zod.z.number().optional(),
|
|
3318
3432
|
updated_at: zod.z.number().optional()
|
|
@@ -3340,8 +3454,8 @@ function updateOrganizationDomainTool(proxy) {
|
|
|
3340
3454
|
//#endregion
|
|
3341
3455
|
//#region src/providers/clerk/tools/update-organization-membership-metadata.ts
|
|
3342
3456
|
const updateOrganizationMembershipMetadataInputSchema = zod.z.object({
|
|
3343
|
-
organization_id: zod.z.string(),
|
|
3344
|
-
user_id: zod.z.string(),
|
|
3457
|
+
organization_id: zod.z.string().min(1),
|
|
3458
|
+
user_id: zod.z.string().min(1),
|
|
3345
3459
|
public_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3346
3460
|
private_metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3347
3461
|
});
|
|
@@ -3378,8 +3492,8 @@ function updateOrganizationMembershipMetadataTool(proxy) {
|
|
|
3378
3492
|
//#endregion
|
|
3379
3493
|
//#region src/providers/clerk/tools/update-organization-membership.ts
|
|
3380
3494
|
const updateOrganizationMembershipInputSchema$1 = zod.z.object({
|
|
3381
|
-
organization_id: zod.z.string(),
|
|
3382
|
-
user_id: zod.z.string(),
|
|
3495
|
+
organization_id: zod.z.string().min(1),
|
|
3496
|
+
user_id: zod.z.string().min(1),
|
|
3383
3497
|
role: zod.z.string()
|
|
3384
3498
|
});
|
|
3385
3499
|
const ResourceSchema$27 = zod.z.object({
|
|
@@ -3412,12 +3526,12 @@ function updateOrganizationMembershipTool$1(proxy) {
|
|
|
3412
3526
|
//#endregion
|
|
3413
3527
|
//#region src/providers/clerk/tools/update-organization-role.ts
|
|
3414
3528
|
const updateOrganizationRoleInputSchema = zod.z.object({
|
|
3415
|
-
organization_role_id: zod.z.string(),
|
|
3529
|
+
organization_role_id: zod.z.string().min(1),
|
|
3416
3530
|
name: zod.z.string().optional(),
|
|
3417
3531
|
key: zod.z.string().optional(),
|
|
3418
3532
|
description: zod.z.string().optional(),
|
|
3419
3533
|
permissions: zod.z.array(zod.z.string()).optional()
|
|
3420
|
-
});
|
|
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." });
|
|
3421
3535
|
const ResourceSchema$26 = zod.z.object({
|
|
3422
3536
|
id: zod.z.string(),
|
|
3423
3537
|
object: zod.z.string().optional(),
|
|
@@ -3461,7 +3575,8 @@ const updateOrganizationInputSchema$1 = zod.z.object({
|
|
|
3461
3575
|
name: zod.z.string().min(1).optional(),
|
|
3462
3576
|
slug: zod.z.string().optional(),
|
|
3463
3577
|
admin_delete_enabled: zod.z.boolean().optional(),
|
|
3464
|
-
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()
|
|
3465
3580
|
});
|
|
3466
3581
|
const OrganizationSchema$1 = zod.z.object({
|
|
3467
3582
|
id: zod.z.string(),
|
|
@@ -3493,7 +3608,8 @@ function updateOrganizationTool$1(proxy) {
|
|
|
3493
3608
|
...input.name !== void 0 && { name: input.name },
|
|
3494
3609
|
...input.slug !== void 0 && { slug: input.slug },
|
|
3495
3610
|
...input.admin_delete_enabled !== void 0 && { admin_delete_enabled: input.admin_delete_enabled },
|
|
3496
|
-
...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 }
|
|
3497
3613
|
},
|
|
3498
3614
|
retries: 3
|
|
3499
3615
|
});
|
|
@@ -3504,7 +3620,7 @@ function updateOrganizationTool$1(proxy) {
|
|
|
3504
3620
|
//#endregion
|
|
3505
3621
|
//#region src/providers/clerk/tools/update-phone-number.ts
|
|
3506
3622
|
const updatePhoneNumberInputSchema = zod.z.object({
|
|
3507
|
-
phone_number_id: zod.z.string(),
|
|
3623
|
+
phone_number_id: zod.z.string().min(1),
|
|
3508
3624
|
verified: zod.z.boolean().optional(),
|
|
3509
3625
|
primary: zod.z.boolean().optional(),
|
|
3510
3626
|
reserved_for_second_factor: zod.z.boolean().optional()
|
|
@@ -3550,14 +3666,14 @@ function updatePhoneNumberTool(proxy) {
|
|
|
3550
3666
|
//#region src/providers/clerk/tools/update-user.ts
|
|
3551
3667
|
const updateUserInputSchema$1 = zod.z.object({
|
|
3552
3668
|
user_id: zod.z.string().min(1),
|
|
3553
|
-
first_name: zod.z.string().optional(),
|
|
3554
|
-
last_name: zod.z.string().optional(),
|
|
3555
|
-
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."),
|
|
3556
3672
|
password: zod.z.string().min(8).optional(),
|
|
3557
3673
|
skip_password_checks: zod.z.boolean().optional(),
|
|
3558
3674
|
sign_out_of_other_sessions: zod.z.boolean().optional(),
|
|
3559
|
-
external_id: zod.z.string().optional(),
|
|
3560
|
-
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.")
|
|
3561
3677
|
});
|
|
3562
3678
|
const UserSchema$24 = zod.z.object({
|
|
3563
3679
|
id: zod.z.string(),
|
|
@@ -3603,24 +3719,30 @@ function updateUserTool$1(proxy) {
|
|
|
3603
3719
|
}
|
|
3604
3720
|
//#endregion
|
|
3605
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());
|
|
3606
3728
|
const verifyOrganizationDomainInputSchema$1 = zod.z.object({
|
|
3607
|
-
organization_id: zod.z.string(),
|
|
3608
|
-
domain_id: zod.z.string()
|
|
3729
|
+
organization_id: zod.z.string().min(1),
|
|
3730
|
+
domain_id: zod.z.string().min(1)
|
|
3609
3731
|
});
|
|
3610
3732
|
const ResourceSchema$24 = zod.z.object({
|
|
3611
3733
|
id: zod.z.string(),
|
|
3612
3734
|
object: zod.z.string().optional(),
|
|
3613
3735
|
organization_id: zod.z.string().optional(),
|
|
3614
3736
|
name: zod.z.string(),
|
|
3615
|
-
enrollment_mode:
|
|
3737
|
+
enrollment_mode: EnrollmentModeSchema.optional(),
|
|
3616
3738
|
affiliation_verification: zod.z.object({
|
|
3617
3739
|
attempts: zod.z.number().optional(),
|
|
3618
3740
|
status: zod.z.string().optional()
|
|
3619
|
-
}).passthrough().optional(),
|
|
3741
|
+
}).passthrough().nullable().optional(),
|
|
3620
3742
|
verification: zod.z.object({
|
|
3621
3743
|
attempts: zod.z.number().optional(),
|
|
3622
3744
|
status: zod.z.string().optional()
|
|
3623
|
-
}).passthrough().optional(),
|
|
3745
|
+
}).passthrough().nullable().optional(),
|
|
3624
3746
|
verified: zod.z.boolean().optional(),
|
|
3625
3747
|
created_at: zod.z.number().optional(),
|
|
3626
3748
|
updated_at: zod.z.number().optional()
|
|
@@ -5178,7 +5300,7 @@ const ChannelSchema$2 = zod.z.object({
|
|
|
5178
5300
|
recipients: zod.z.array(zod.z.unknown()).optional(),
|
|
5179
5301
|
icon: zod.z.string().nullable().optional(),
|
|
5180
5302
|
owner_id: zod.z.string().optional(),
|
|
5181
|
-
application_id: zod.z.string().optional(),
|
|
5303
|
+
application_id: zod.z.string().nullable().optional(),
|
|
5182
5304
|
managed: zod.z.boolean().optional(),
|
|
5183
5305
|
parent_id: zod.z.string().nullable().optional(),
|
|
5184
5306
|
last_pin_timestamp: zod.z.string().nullable().optional(),
|
|
@@ -55243,7 +55365,7 @@ const cancelEmailInputSchema = zod.z.object({ email_id: zod.z.string() });
|
|
|
55243
55365
|
const ProviderResponseSchema$107 = zod.z.object({
|
|
55244
55366
|
object: zod.z.string().optional(),
|
|
55245
55367
|
id: zod.z.string().optional(),
|
|
55246
|
-
message_id: zod.z.string().optional(),
|
|
55368
|
+
message_id: zod.z.string().nullable().optional(),
|
|
55247
55369
|
to: zod.z.array(zod.z.string()).optional(),
|
|
55248
55370
|
from: zod.z.string().optional(),
|
|
55249
55371
|
created_at: zod.z.string().optional(),
|
|
@@ -56493,7 +56615,7 @@ const getEmailInputSchema = zod.z.object({ email_id: zod.z.string() });
|
|
|
56493
56615
|
const ProviderResponseSchema$76 = zod.z.object({
|
|
56494
56616
|
object: zod.z.string().optional(),
|
|
56495
56617
|
id: zod.z.string().optional(),
|
|
56496
|
-
message_id: zod.z.string().optional(),
|
|
56618
|
+
message_id: zod.z.string().nullable().optional(),
|
|
56497
56619
|
to: zod.z.array(zod.z.string()).optional(),
|
|
56498
56620
|
from: zod.z.string().optional(),
|
|
56499
56621
|
created_at: zod.z.string().optional(),
|
|
@@ -56580,7 +56702,7 @@ const ProviderResponseSchema$74 = zod.z.object({
|
|
|
56580
56702
|
to: zod.z.array(zod.z.string()).optional(),
|
|
56581
56703
|
from: zod.z.string().optional(),
|
|
56582
56704
|
subject: zod.z.string().optional(),
|
|
56583
|
-
message_id: zod.z.string().optional(),
|
|
56705
|
+
message_id: zod.z.string().nullable().optional(),
|
|
56584
56706
|
bcc: zod.z.array(zod.z.string()).nullable().optional(),
|
|
56585
56707
|
cc: zod.z.array(zod.z.string()).nullable().optional(),
|
|
56586
56708
|
reply_to: zod.z.array(zod.z.string()).nullable().optional(),
|
|
@@ -56654,7 +56776,7 @@ const ProviderResponseSchema$72 = zod.z.object({
|
|
|
56654
56776
|
current_version_id: zod.z.string().optional(),
|
|
56655
56777
|
name: zod.z.string().optional(),
|
|
56656
56778
|
alias: zod.z.string().optional(),
|
|
56657
|
-
from: zod.z.string().optional(),
|
|
56779
|
+
from: zod.z.string().nullable().optional(),
|
|
56658
56780
|
subject: zod.z.string().optional(),
|
|
56659
56781
|
reply_to: zod.z.array(zod.z.string()).nullable().optional(),
|
|
56660
56782
|
html: zod.z.string().optional(),
|
|
@@ -57377,7 +57499,7 @@ const ProviderResponseSchema$57 = zod.z.object({
|
|
|
57377
57499
|
data: zod.z.array(zod.z.object({
|
|
57378
57500
|
object: zod.z.string().optional(),
|
|
57379
57501
|
id: zod.z.string().optional(),
|
|
57380
|
-
message_id: zod.z.string().optional(),
|
|
57502
|
+
message_id: zod.z.string().nullable().optional(),
|
|
57381
57503
|
to: zod.z.array(zod.z.string()).optional(),
|
|
57382
57504
|
from: zod.z.string().optional(),
|
|
57383
57505
|
created_at: zod.z.string().optional(),
|
|
@@ -57496,7 +57618,7 @@ const ProviderResponseSchema$55 = zod.z.object({
|
|
|
57496
57618
|
to: zod.z.array(zod.z.string()).optional(),
|
|
57497
57619
|
from: zod.z.string().optional(),
|
|
57498
57620
|
subject: zod.z.string().nullable().optional(),
|
|
57499
|
-
message_id: zod.z.string().optional(),
|
|
57621
|
+
message_id: zod.z.string().nullable().optional(),
|
|
57500
57622
|
bcc: zod.z.array(zod.z.string()).nullable().optional(),
|
|
57501
57623
|
cc: zod.z.array(zod.z.string()).nullable().optional(),
|
|
57502
57624
|
reply_to: zod.z.array(zod.z.string()).nullable().optional(),
|
|
@@ -58184,7 +58306,7 @@ function updateContactTopicsTool(proxy) {
|
|
|
58184
58306
|
const config = {
|
|
58185
58307
|
endpoint: `/contacts/${encodeURIComponent(input["contact_id"])}/topics`,
|
|
58186
58308
|
retries: 3,
|
|
58187
|
-
data: input.body
|
|
58309
|
+
data: input.body.topics
|
|
58188
58310
|
};
|
|
58189
58311
|
const response = await platformProxy.patch(config);
|
|
58190
58312
|
return ProviderResponseSchema$39.parse(response.data);
|
|
@@ -74136,8 +74258,10 @@ let nextResolverId = 0;
|
|
|
74136
74258
|
* to (or detached from) the project are picked up (or dropped) without a
|
|
74137
74259
|
* restart.
|
|
74138
74260
|
*
|
|
74139
|
-
* Configuration errors (missing project id, bad ttlMs, malformed integration id
|
|
74140
|
-
* 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.
|
|
74141
74265
|
* Expected provider absence is silently skipped. Actionable per-integration
|
|
74142
74266
|
* problems during resolution (needs re-auth or ambiguity) are downgraded to
|
|
74143
74267
|
* warn-and-skip so one bad integration never takes down the whole toolset.
|
|
@@ -74153,6 +74277,8 @@ function tools(options = {}) {
|
|
|
74153
74277
|
const integrationOverrides = normalizeIntegrationOverrides(options.integrations);
|
|
74154
74278
|
validateIntegrationOverrides(integrationOverrides);
|
|
74155
74279
|
validateIntegrationXor(integrationOverrides);
|
|
74280
|
+
validateRequireApproval(integrationOverrides);
|
|
74281
|
+
rejectRemovedAutoApproveTools(integrationOverrides);
|
|
74156
74282
|
let cache;
|
|
74157
74283
|
let inflight;
|
|
74158
74284
|
let closing;
|
|
@@ -74271,6 +74397,30 @@ function validateIntegrationXor(integrations) {
|
|
|
74271
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.`);
|
|
74272
74398
|
}
|
|
74273
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
|
+
}
|
|
74274
74424
|
function buildRequests(integrations, catalog) {
|
|
74275
74425
|
const overrides = integrations;
|
|
74276
74426
|
const registrations = new Map(TOOLS.map((registration) => [registration.integrationId, registration]));
|
|
@@ -74320,16 +74470,19 @@ async function mapTools(connections, requests, options, client, mcpClients, reso
|
|
|
74320
74470
|
connectionId: resolution.connectionId,
|
|
74321
74471
|
allowTools: request.options.allowTools,
|
|
74322
74472
|
disallowTools: request.options.disallowTools,
|
|
74323
|
-
|
|
74473
|
+
requireApproval: request.options.requireApproval,
|
|
74324
74474
|
client,
|
|
74325
74475
|
mcpClients,
|
|
74326
74476
|
resolverId
|
|
74327
74477
|
});
|
|
74328
|
-
} else
|
|
74329
|
-
|
|
74330
|
-
|
|
74331
|
-
|
|
74332
|
-
|
|
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
|
+
}
|
|
74333
74486
|
else if (request.registration.transport === "mcp") {
|
|
74334
74487
|
for (const connection of resolution.connections) activeMcpKeys.add(`${integrationId}::${connection.id}`);
|
|
74335
74488
|
providerTools = await buildMcpMultiConnectionTools({
|
|
@@ -74337,19 +74490,23 @@ async function mapTools(connections, requests, options, client, mcpClients, reso
|
|
|
74337
74490
|
connections: resolution.connections,
|
|
74338
74491
|
allowTools: request.options.allowTools,
|
|
74339
74492
|
disallowTools: request.options.disallowTools,
|
|
74340
|
-
|
|
74493
|
+
requireApproval: request.options.requireApproval,
|
|
74341
74494
|
client,
|
|
74342
74495
|
mcpClients,
|
|
74343
74496
|
resolverId
|
|
74344
74497
|
});
|
|
74345
|
-
} else
|
|
74346
|
-
|
|
74347
|
-
|
|
74348
|
-
|
|
74349
|
-
|
|
74350
|
-
|
|
74351
|
-
|
|
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
|
+
}
|
|
74352
74508
|
} catch (error) {
|
|
74509
|
+
if (error instanceof MastraConnectConfigError) throw error;
|
|
74353
74510
|
console.warn(`[@mastra/connect] Skipping ${integrationId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
74354
74511
|
continue;
|
|
74355
74512
|
}
|
|
@@ -74373,9 +74530,33 @@ async function mapTools(connections, requests, options, client, mcpClients, reso
|
|
|
74373
74530
|
function providerFilterOptions(options) {
|
|
74374
74531
|
return options.allowTools !== void 0 ? { allowTools: options.allowTools } : options.disallowTools !== void 0 ? { disallowTools: options.disallowTools } : {};
|
|
74375
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
|
+
}
|
|
74376
74557
|
async function discoverMcpTools(input) {
|
|
74377
|
-
const { registration, connectionId, allowTools, disallowTools,
|
|
74378
|
-
const
|
|
74558
|
+
const { registration, connectionId, allowTools, disallowTools, requireApproval, client, mcpClients, resolverId } = input;
|
|
74559
|
+
const requireApprovalFor = Array.isArray(requireApproval) ? new Set(requireApproval) : void 0;
|
|
74379
74560
|
const cacheKey = `${registration.integrationId}::${connectionId}`;
|
|
74380
74561
|
let entry = mcpClients.get(cacheKey);
|
|
74381
74562
|
if (!entry) {
|
|
@@ -74387,7 +74568,7 @@ async function discoverMcpTools(input) {
|
|
|
74387
74568
|
id: `mastra-connect-${resolverId}-${registration.integrationId}-${connectionId}`,
|
|
74388
74569
|
servers: { [registration.integrationId]: {
|
|
74389
74570
|
...transport,
|
|
74390
|
-
requireToolApproval: ({ toolName }) =>
|
|
74571
|
+
...requireApproval === true ? { requireToolApproval: true } : requireApprovalFor ? { requireToolApproval: ({ toolName }) => requireApprovalFor.has(`${registration.integrationId}_${String(toolName)}`) } : {}
|
|
74391
74572
|
} }
|
|
74392
74573
|
})
|
|
74393
74574
|
};
|
|
@@ -74396,8 +74577,10 @@ async function discoverMcpTools(input) {
|
|
|
74396
74577
|
const discovery = await entry.client.listToolsWithErrors();
|
|
74397
74578
|
const error = discovery.errors[registration.integrationId];
|
|
74398
74579
|
if (error) throw new Error(`MCP tool discovery failed: ${error}`);
|
|
74399
|
-
|
|
74400
|
-
|
|
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
|
+
}
|
|
74401
74584
|
return applyToolFilter(discovery.tools, {
|
|
74402
74585
|
allowTools,
|
|
74403
74586
|
disallowTools
|
|
@@ -74499,6 +74682,7 @@ async function channels(options = {}) {
|
|
|
74499
74682
|
let cache;
|
|
74500
74683
|
let inflight;
|
|
74501
74684
|
let lastFailureAt;
|
|
74685
|
+
let warnedStaleSlackConnection = false;
|
|
74502
74686
|
const buildSnapshot = async () => {
|
|
74503
74687
|
let connections;
|
|
74504
74688
|
try {
|
|
@@ -74509,6 +74693,10 @@ async function channels(options = {}) {
|
|
|
74509
74693
|
}
|
|
74510
74694
|
const byIntegrationId = groupByIntegrationId(connections);
|
|
74511
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
|
+
}
|
|
74512
74700
|
for (const state of states) {
|
|
74513
74701
|
const integrationId = state.registration.integrationId;
|
|
74514
74702
|
const overrides = options.integrations?.[integrationId] ?? {};
|
|
@@ -74620,7 +74808,9 @@ async function credential(connectionId, options) {
|
|
|
74620
74808
|
//#endregion
|
|
74621
74809
|
//#region src/environment.ts
|
|
74622
74810
|
function credentialToken(credential) {
|
|
74623
|
-
|
|
74811
|
+
if (credential.type === "oauth2") return credential.accessToken;
|
|
74812
|
+
if (credential.type === "two_step") return credential.token;
|
|
74813
|
+
return credential.apiKey;
|
|
74624
74814
|
}
|
|
74625
74815
|
/**
|
|
74626
74816
|
* Wires git's credential helper to read the token from the environment at use
|