@mastra/connect 1.0.0 → 1.0.1-alpha.1

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/dist/index.cjs CHANGED
@@ -5479,7 +5479,7 @@ const listGuildMembersInputSchema = zod.z.object({
5479
5479
  limit: zod.z.number().min(1).max(1e3).optional().describe("Max number of members to return (1-1000)."),
5480
5480
  after: zod.z.string().optional().describe("The highest user id in the previous page. Omit for the first page.")
5481
5481
  });
5482
- const ProviderUserSchema$22 = zod.z.object({
5482
+ const ProviderUserSchema$23 = zod.z.object({
5483
5483
  id: zod.z.string(),
5484
5484
  username: zod.z.string(),
5485
5485
  discriminator: zod.z.string(),
@@ -5488,8 +5488,8 @@ const ProviderUserSchema$22 = zod.z.object({
5488
5488
  bot: zod.z.boolean().optional(),
5489
5489
  system: zod.z.boolean().optional()
5490
5490
  });
5491
- const ProviderGuildMemberSchema = zod.z.object({
5492
- user: ProviderUserSchema$22.optional(),
5491
+ const ProviderGuildMemberSchema$1 = zod.z.object({
5492
+ user: ProviderUserSchema$23.optional(),
5493
5493
  nick: zod.z.string().nullable().optional(),
5494
5494
  avatar: zod.z.string().nullable().optional(),
5495
5495
  banner: zod.z.string().nullable().optional(),
@@ -5505,7 +5505,7 @@ const ProviderGuildMemberSchema = zod.z.object({
5505
5505
  avatar_decoration_data: zod.z.unknown().nullable().optional(),
5506
5506
  collectibles: zod.z.unknown().nullable().optional()
5507
5507
  });
5508
- const OutputMemberSchema = zod.z.object({
5508
+ const OutputMemberSchema$1 = zod.z.object({
5509
5509
  user: zod.z.object({
5510
5510
  id: zod.z.string(),
5511
5511
  username: zod.z.string(),
@@ -5529,7 +5529,7 @@ const OutputMemberSchema = zod.z.object({
5529
5529
  communication_disabled_until: zod.z.string().optional()
5530
5530
  });
5531
5531
  const listGuildMembersOutputSchema = zod.z.object({
5532
- items: zod.z.array(OutputMemberSchema),
5532
+ items: zod.z.array(OutputMemberSchema$1),
5533
5533
  next_after: zod.z.string().optional()
5534
5534
  });
5535
5535
  function listGuildMembersTool(proxy) {
@@ -5555,7 +5555,7 @@ function listGuildMembersTool(proxy) {
5555
5555
  const items = [];
5556
5556
  let lastUserId;
5557
5557
  for (const rawMember of rawMembers) {
5558
- const providerMember = ProviderGuildMemberSchema.parse(rawMember);
5558
+ const providerMember = ProviderGuildMemberSchema$1.parse(rawMember);
5559
5559
  const user = providerMember.user ? {
5560
5560
  id: providerMember.user.id,
5561
5561
  username: providerMember.user.username,
@@ -5974,6 +5974,109 @@ function removeGuildMemberRoleTool(proxy) {
5974
5974
  });
5975
5975
  }
5976
5976
  //#endregion
5977
+ //#region src/providers/discord/tools/search-members.ts
5978
+ const searchMembersInputSchema = zod.z.object({
5979
+ guild_id: zod.z.string().describe("Guild ID. Example: \"197038439483310086\""),
5980
+ query: zod.z.string().min(1).describe("Username or nickname prefix to search for."),
5981
+ limit: zod.z.number().int().min(1).max(1e3).optional().describe("Max number of members to return (1-1000). Default: 25.")
5982
+ });
5983
+ const ProviderUserSchema$22 = zod.z.object({
5984
+ id: zod.z.string(),
5985
+ username: zod.z.string(),
5986
+ discriminator: zod.z.string(),
5987
+ global_name: zod.z.string().nullable().optional(),
5988
+ avatar: zod.z.string().nullable().optional(),
5989
+ bot: zod.z.boolean().optional(),
5990
+ system: zod.z.boolean().optional()
5991
+ });
5992
+ const ProviderGuildMemberSchema = zod.z.object({
5993
+ user: ProviderUserSchema$22.optional(),
5994
+ nick: zod.z.string().nullable().optional(),
5995
+ avatar: zod.z.string().nullable().optional(),
5996
+ roles: zod.z.array(zod.z.string()),
5997
+ joined_at: zod.z.string().nullable(),
5998
+ premium_since: zod.z.string().nullable().optional(),
5999
+ deaf: zod.z.boolean(),
6000
+ mute: zod.z.boolean(),
6001
+ flags: zod.z.number(),
6002
+ pending: zod.z.boolean().optional(),
6003
+ permissions: zod.z.string().optional(),
6004
+ communication_disabled_until: zod.z.string().nullable().optional()
6005
+ });
6006
+ const OutputMemberSchema = zod.z.object({
6007
+ user: zod.z.object({
6008
+ id: zod.z.string(),
6009
+ username: zod.z.string(),
6010
+ discriminator: zod.z.string(),
6011
+ global_name: zod.z.string().optional(),
6012
+ avatar: zod.z.string().optional(),
6013
+ bot: zod.z.boolean().optional(),
6014
+ system: zod.z.boolean().optional()
6015
+ }).optional(),
6016
+ nick: zod.z.string().optional(),
6017
+ avatar: zod.z.string().optional(),
6018
+ roles: zod.z.array(zod.z.string()),
6019
+ joined_at: zod.z.string().optional(),
6020
+ premium_since: zod.z.string().optional(),
6021
+ deaf: zod.z.boolean(),
6022
+ mute: zod.z.boolean(),
6023
+ flags: zod.z.number(),
6024
+ pending: zod.z.boolean().optional(),
6025
+ permissions: zod.z.string().optional(),
6026
+ communication_disabled_until: zod.z.string().optional()
6027
+ });
6028
+ const searchMembersOutputSchema = zod.z.object({ items: zod.z.array(OutputMemberSchema) });
6029
+ function searchMembersTool(proxy) {
6030
+ return (0, _mastra_core_tools.createTool)({
6031
+ id: "discord_search_members",
6032
+ description: "Search guild members whose username or nickname starts with the query, instead of paging the full member list.",
6033
+ inputSchema: searchMembersInputSchema,
6034
+ outputSchema: searchMembersOutputSchema,
6035
+ execute: async (input, { requestContext }) => {
6036
+ const platformProxy = proxy.withRequestContext(requestContext);
6037
+ const botToken = await resolveDiscordBotToken(platformProxy);
6038
+ const response = await platformProxy.get({
6039
+ endpoint: `/api/v10/guilds/${input.guild_id}/members/search`,
6040
+ params: {
6041
+ query: input.query,
6042
+ limit: String(input.limit ?? 25)
6043
+ },
6044
+ headers: { Authorization: `Bot ${botToken}` },
6045
+ retries: 3
6046
+ });
6047
+ const rawMembers = zod.z.array(zod.z.unknown()).parse(response.data);
6048
+ const items = [];
6049
+ for (const rawMember of rawMembers) {
6050
+ const providerMember = ProviderGuildMemberSchema.parse(rawMember);
6051
+ const user = providerMember.user ? {
6052
+ id: providerMember.user.id,
6053
+ username: providerMember.user.username,
6054
+ discriminator: providerMember.user.discriminator,
6055
+ ...providerMember.user.global_name != null && { global_name: providerMember.user.global_name },
6056
+ ...providerMember.user.avatar != null && { avatar: providerMember.user.avatar },
6057
+ ...providerMember.user.bot !== void 0 && { bot: providerMember.user.bot },
6058
+ ...providerMember.user.system !== void 0 && { system: providerMember.user.system }
6059
+ } : void 0;
6060
+ items.push({
6061
+ ...user !== void 0 && { user },
6062
+ ...providerMember.nick != null && { nick: providerMember.nick },
6063
+ ...providerMember.avatar != null && { avatar: providerMember.avatar },
6064
+ roles: providerMember.roles,
6065
+ ...providerMember.joined_at != null && { joined_at: providerMember.joined_at },
6066
+ ...providerMember.premium_since != null && { premium_since: providerMember.premium_since },
6067
+ deaf: providerMember.deaf,
6068
+ mute: providerMember.mute,
6069
+ flags: providerMember.flags,
6070
+ ...providerMember.pending !== void 0 && { pending: providerMember.pending },
6071
+ ...providerMember.permissions !== void 0 && { permissions: providerMember.permissions },
6072
+ ...providerMember.communication_disabled_until != null && { communication_disabled_until: providerMember.communication_disabled_until }
6073
+ });
6074
+ }
6075
+ return { items };
6076
+ }
6077
+ });
6078
+ }
6079
+ //#endregion
5977
6080
  //#region src/providers/discord/tools/update-channel.ts
5978
6081
  const updateChannelInputSchema$1 = zod.z.object({
5979
6082
  channel_id: zod.z.string().describe("The ID of the channel to update. Example: \"1504364254634180618\""),
@@ -6656,6 +6759,7 @@ function createDiscordTools(options) {
6656
6759
  discord_list_roles: listRolesTool$1(platformProxy),
6657
6760
  discord_list_webhooks: listWebhooksTool$1(platformProxy),
6658
6761
  discord_remove_guild_member_role: removeGuildMemberRoleTool(platformProxy),
6762
+ discord_search_members: searchMembersTool(platformProxy),
6659
6763
  discord_update_channel: updateChannelTool$1(platformProxy),
6660
6764
  discord_update_guild_member: updateGuildMemberTool(platformProxy),
6661
6765
  discord_update_guild: updateGuildTool(platformProxy),
@@ -8339,13 +8443,13 @@ const ProviderContactSchema = zod.z.object({
8339
8443
  picture: zod.z.string().nullable(),
8340
8444
  last_meeting_date: zod.z.string().nullable()
8341
8445
  });
8342
- const ContactSchema$1 = zod.z.object({
8446
+ const ContactSchema$2 = zod.z.object({
8343
8447
  email: zod.z.string(),
8344
8448
  name: zod.z.string().optional(),
8345
8449
  picture: zod.z.string().optional(),
8346
8450
  last_meeting_date: zod.z.string().optional()
8347
8451
  });
8348
- const listContactsOutputSchema$2 = zod.z.object({ contacts: zod.z.array(ContactSchema$1) });
8452
+ const listContactsOutputSchema$2 = zod.z.object({ contacts: zod.z.array(ContactSchema$2) });
8349
8453
  function listContactsTool$2(proxy) {
8350
8454
  return (0, _mastra_core_tools.createTool)({
8351
8455
  id: "fireflies_list_contacts",
@@ -12764,6 +12868,229 @@ function rerunWorkflowRunTool(proxy) {
12764
12868
  });
12765
12869
  }
12766
12870
  //#endregion
12871
+ //#region src/providers/github/tools/search-code.ts
12872
+ const searchCodeInputSchema = zod.z.object({
12873
+ q: zod.z.string().min(1).describe("GitHub code search query. Must include at least one qualifier such as repo:owner/name, org:name, or user:name. Example: \"createTool repo:mastra-ai/mastra language:typescript\"."),
12874
+ per_page: zod.z.number().int().min(1).max(100).optional().describe("The number of results per page (max 100)."),
12875
+ cursor: zod.z.string().regex(/^[1-9]\d*$/, "Cursor must be a positive page number.").refine((value) => Number.isSafeInteger(Number.parseInt(value, 10)), "Cursor must be a positive page number.").optional().describe("Pagination cursor (page number). Omit for the first page.")
12876
+ });
12877
+ const SearchCodeItemSchema = zod.z.object({
12878
+ name: zod.z.string(),
12879
+ path: zod.z.string(),
12880
+ sha: zod.z.string(),
12881
+ html_url: zod.z.string(),
12882
+ repository_full_name: zod.z.string().optional()
12883
+ });
12884
+ const searchCodeOutputSchema = zod.z.object({
12885
+ total_count: zod.z.number(),
12886
+ incomplete_results: zod.z.boolean(),
12887
+ items: zod.z.array(SearchCodeItemSchema),
12888
+ next_cursor: zod.z.string().optional()
12889
+ });
12890
+ function searchCodeTool(proxy) {
12891
+ return (0, _mastra_core_tools.createTool)({
12892
+ id: "github_search_code",
12893
+ description: "Search file contents across GitHub repositories. The query must be scoped with a repo:, org:, or user: qualifier.",
12894
+ inputSchema: searchCodeInputSchema,
12895
+ outputSchema: searchCodeOutputSchema,
12896
+ execute: async (input, { requestContext }) => {
12897
+ const platformProxy = proxy.withRequestContext(requestContext);
12898
+ const page = input.cursor ? Number.parseInt(input.cursor, 10) : 1;
12899
+ const perPage = input.per_page ?? 30;
12900
+ const data = (await platformProxy.get({
12901
+ endpoint: "search/code",
12902
+ params: {
12903
+ q: input.q,
12904
+ per_page: perPage,
12905
+ page
12906
+ },
12907
+ retries: 3
12908
+ })).data;
12909
+ const items = (data.items || []).map((item) => ({
12910
+ name: item.name,
12911
+ path: item.path,
12912
+ sha: item.sha,
12913
+ html_url: item.html_url,
12914
+ repository_full_name: item.repository?.full_name ?? void 0
12915
+ }));
12916
+ const reachableResults = Math.min(data.total_count ?? 0, 1e3);
12917
+ const hasMore = page * perPage < reachableResults && items.length === perPage;
12918
+ return {
12919
+ total_count: data.total_count ?? 0,
12920
+ incomplete_results: data.incomplete_results ?? false,
12921
+ items,
12922
+ ...hasMore && { next_cursor: String(page + 1) }
12923
+ };
12924
+ }
12925
+ });
12926
+ }
12927
+ //#endregion
12928
+ //#region src/providers/github/tools/search-issues.ts
12929
+ const searchIssuesInputSchema$2 = zod.z.object({
12930
+ q: zod.z.string().min(1).describe("GitHub search query. Supports qualifiers like repo:owner/name, is:issue, is:pr, is:open, label:bug, author:user. Example: \"repo:mastra-ai/mastra is:issue is:open label:bug\"."),
12931
+ sort: zod.z.enum([
12932
+ "comments",
12933
+ "reactions",
12934
+ "created",
12935
+ "updated"
12936
+ ]).optional().describe("What to sort results by. Default: best match."),
12937
+ order: zod.z.enum(["asc", "desc"]).optional().describe("The direction to sort the results by. Default: desc."),
12938
+ per_page: zod.z.number().int().min(1).max(100).optional().describe("The number of results per page (max 100)."),
12939
+ cursor: zod.z.string().regex(/^[1-9]\d*$/, "Cursor must be a positive page number.").refine((value) => Number.isSafeInteger(Number.parseInt(value, 10)), "Cursor must be a positive page number.").optional().describe("Pagination cursor (page number). Omit for the first page.")
12940
+ });
12941
+ const SearchIssueSchema = zod.z.object({
12942
+ id: zod.z.number(),
12943
+ number: zod.z.number(),
12944
+ title: zod.z.string(),
12945
+ state: zod.z.string(),
12946
+ html_url: zod.z.string(),
12947
+ repository_url: zod.z.string(),
12948
+ user_login: zod.z.string().optional(),
12949
+ labels: zod.z.array(zod.z.string()),
12950
+ is_pull_request: zod.z.boolean(),
12951
+ comments: zod.z.number(),
12952
+ created_at: zod.z.string(),
12953
+ updated_at: zod.z.string()
12954
+ });
12955
+ const searchIssuesOutputSchema$2 = zod.z.object({
12956
+ total_count: zod.z.number(),
12957
+ incomplete_results: zod.z.boolean(),
12958
+ items: zod.z.array(SearchIssueSchema),
12959
+ next_cursor: zod.z.string().optional()
12960
+ });
12961
+ function searchIssuesTool$2(proxy) {
12962
+ return (0, _mastra_core_tools.createTool)({
12963
+ id: "github_search_issues",
12964
+ description: "Search issues and pull requests across GitHub with the search API instead of paging repository listings. Supports the full GitHub search query syntax.",
12965
+ inputSchema: searchIssuesInputSchema$2,
12966
+ outputSchema: searchIssuesOutputSchema$2,
12967
+ execute: async (input, { requestContext }) => {
12968
+ const platformProxy = proxy.withRequestContext(requestContext);
12969
+ const page = input.cursor ? Number.parseInt(input.cursor, 10) : 1;
12970
+ const perPage = input.per_page ?? 30;
12971
+ const data = (await platformProxy.get({
12972
+ endpoint: "search/issues",
12973
+ params: {
12974
+ q: input.q,
12975
+ ...input.sort !== void 0 && { sort: input.sort },
12976
+ ...input.order !== void 0 && { order: input.order },
12977
+ per_page: perPage,
12978
+ page
12979
+ },
12980
+ retries: 3
12981
+ })).data;
12982
+ const items = (data.items || []).map((item) => ({
12983
+ id: item.id,
12984
+ number: item.number,
12985
+ title: item.title,
12986
+ state: item.state,
12987
+ html_url: item.html_url,
12988
+ repository_url: item.repository_url,
12989
+ user_login: item.user?.login ?? void 0,
12990
+ labels: (item.labels || []).map((label) => typeof label === "string" ? label : label.name || ""),
12991
+ is_pull_request: item.pull_request !== void 0,
12992
+ comments: item.comments ?? 0,
12993
+ created_at: item.created_at,
12994
+ updated_at: item.updated_at
12995
+ }));
12996
+ const reachableResults = Math.min(data.total_count ?? 0, 1e3);
12997
+ const hasMore = page * perPage < reachableResults && items.length === perPage;
12998
+ return {
12999
+ total_count: data.total_count ?? 0,
13000
+ incomplete_results: data.incomplete_results ?? false,
13001
+ items,
13002
+ ...hasMore && { next_cursor: String(page + 1) }
13003
+ };
13004
+ }
13005
+ });
13006
+ }
13007
+ //#endregion
13008
+ //#region src/providers/github/tools/search-repositories.ts
13009
+ const searchRepositoriesInputSchema = zod.z.object({
13010
+ q: zod.z.string().min(1).describe("GitHub search query. Supports qualifiers like org:mastra-ai, user:someone, language:typescript, topic:ai. Example: \"org:mastra-ai mastra in:name\"."),
13011
+ sort: zod.z.enum([
13012
+ "stars",
13013
+ "forks",
13014
+ "help-wanted-issues",
13015
+ "updated"
13016
+ ]).optional().describe("What to sort results by. Default: best match."),
13017
+ order: zod.z.enum(["asc", "desc"]).optional().describe("The direction to sort the results by. Default: desc."),
13018
+ per_page: zod.z.number().int().min(1).max(100).optional().describe("The number of results per page (max 100)."),
13019
+ cursor: zod.z.string().regex(/^[1-9]\d*$/, "Cursor must be a positive page number.").refine((value) => Number.isSafeInteger(Number.parseInt(value, 10)), "Cursor must be a positive page number.").optional().describe("Pagination cursor (page number). Omit for the first page.")
13020
+ });
13021
+ const SearchRepositorySchema = zod.z.object({
13022
+ id: zod.z.number(),
13023
+ name: zod.z.string(),
13024
+ full_name: zod.z.string(),
13025
+ owner_login: zod.z.string().optional(),
13026
+ html_url: zod.z.string(),
13027
+ description: zod.z.string().nullable().optional(),
13028
+ private: zod.z.boolean(),
13029
+ fork: zod.z.boolean(),
13030
+ archived: zod.z.boolean().optional(),
13031
+ language: zod.z.string().nullable().optional(),
13032
+ default_branch: zod.z.string().optional(),
13033
+ stargazers_count: zod.z.number().optional(),
13034
+ forks_count: zod.z.number().optional(),
13035
+ open_issues_count: zod.z.number().optional(),
13036
+ updated_at: zod.z.string().optional()
13037
+ });
13038
+ const searchRepositoriesOutputSchema = zod.z.object({
13039
+ total_count: zod.z.number(),
13040
+ incomplete_results: zod.z.boolean(),
13041
+ items: zod.z.array(SearchRepositorySchema),
13042
+ next_cursor: zod.z.string().optional()
13043
+ });
13044
+ function searchRepositoriesTool(proxy) {
13045
+ return (0, _mastra_core_tools.createTool)({
13046
+ id: "github_search_repositories",
13047
+ description: "Search repositories across GitHub by name, organization, language, or topic instead of needing to know the exact owner/repo up front.",
13048
+ inputSchema: searchRepositoriesInputSchema,
13049
+ outputSchema: searchRepositoriesOutputSchema,
13050
+ execute: async (input, { requestContext }) => {
13051
+ const platformProxy = proxy.withRequestContext(requestContext);
13052
+ const page = input.cursor ? Number.parseInt(input.cursor, 10) : 1;
13053
+ const perPage = input.per_page ?? 30;
13054
+ const data = (await platformProxy.get({
13055
+ endpoint: "search/repositories",
13056
+ params: {
13057
+ q: input.q,
13058
+ ...input.sort !== void 0 && { sort: input.sort },
13059
+ ...input.order !== void 0 && { order: input.order },
13060
+ per_page: perPage,
13061
+ page
13062
+ },
13063
+ retries: 3
13064
+ })).data;
13065
+ const items = (data.items || []).map((item) => ({
13066
+ id: item.id,
13067
+ name: item.name,
13068
+ full_name: item.full_name,
13069
+ owner_login: item.owner?.login ?? void 0,
13070
+ html_url: item.html_url,
13071
+ description: item.description ?? void 0,
13072
+ private: item.private ?? false,
13073
+ fork: item.fork ?? false,
13074
+ archived: item.archived,
13075
+ language: item.language ?? void 0,
13076
+ default_branch: item.default_branch,
13077
+ stargazers_count: item.stargazers_count,
13078
+ forks_count: item.forks_count,
13079
+ open_issues_count: item.open_issues_count,
13080
+ updated_at: item.updated_at
13081
+ }));
13082
+ const reachableResults = Math.min(data.total_count ?? 0, 1e3);
13083
+ const hasMore = page * perPage < reachableResults && items.length === perPage;
13084
+ return {
13085
+ total_count: data.total_count ?? 0,
13086
+ incomplete_results: data.incomplete_results ?? false,
13087
+ items,
13088
+ ...hasMore && { next_cursor: String(page + 1) }
13089
+ };
13090
+ }
13091
+ });
13092
+ }
13093
+ //#endregion
12767
13094
  //#region src/providers/github/tools/submit-pull-request-review.ts
12768
13095
  const InlineCommentSchema = zod.z.object({
12769
13096
  path: zod.z.string().describe("The relative path to the file that necessitates a review comment."),
@@ -13478,6 +13805,9 @@ function createGithubTools(options) {
13478
13805
  github_list_workflows: listWorkflowsTool(platformProxy),
13479
13806
  github_merge_pull_request: mergePullRequestTool(platformProxy),
13480
13807
  github_rerun_workflow_run: rerunWorkflowRunTool(platformProxy),
13808
+ github_search_code: searchCodeTool(platformProxy),
13809
+ github_search_issues: searchIssuesTool$2(platformProxy),
13810
+ github_search_repositories: searchRepositoriesTool(platformProxy),
13481
13811
  github_submit_pull_request_review: submitPullRequestReviewTool(platformProxy),
13482
13812
  github_update_issue: updateIssueTool$2(platformProxy),
13483
13813
  github_update_label: updateLabelTool$1(platformProxy),
@@ -27633,7 +27963,7 @@ function listCompaniesTool(proxy) {
27633
27963
  //#endregion
27634
27964
  //#region src/providers/hubspot/tools/list-contacts.ts
27635
27965
  const listContactsInputSchema$1 = zod.z.object({ cursor: zod.z.string().optional().describe("Pagination cursor from previous response. Omit for first page.") });
27636
- const ContactSchema = zod.z.object({
27966
+ const ContactSchema$1 = zod.z.object({
27637
27967
  id: zod.z.string(),
27638
27968
  email: zod.z.string().optional(),
27639
27969
  firstName: zod.z.string().optional(),
@@ -27643,7 +27973,7 @@ const ContactSchema = zod.z.object({
27643
27973
  updatedAt: zod.z.string().optional()
27644
27974
  });
27645
27975
  const listContactsOutputSchema$1 = zod.z.object({
27646
- contacts: zod.z.array(ContactSchema),
27976
+ contacts: zod.z.array(ContactSchema$1),
27647
27977
  nextCursor: zod.z.string().optional()
27648
27978
  });
27649
27979
  function listContactsTool$1(proxy) {
@@ -27953,6 +28283,95 @@ function searchCompaniesTool(proxy) {
27953
28283
  });
27954
28284
  }
27955
28285
  //#endregion
28286
+ //#region src/providers/hubspot/tools/search-contacts.ts
28287
+ const searchContactsInputSchema = zod.z.object({
28288
+ query: zod.z.string().optional().describe("Free-text search across default searchable contact properties (name, email, phone, company)."),
28289
+ email: zod.z.string().optional().describe("Contact email to search for (exact match)."),
28290
+ firstname: zod.z.string().optional().describe("Contact first name to search for."),
28291
+ lastname: zod.z.string().optional().describe("Contact last name to search for."),
28292
+ company: zod.z.string().optional().describe("Contact company name to search for."),
28293
+ cursor: zod.z.string().optional().describe("Pagination cursor from previous response. Omit for first page.")
28294
+ });
28295
+ const ContactSchema = zod.z.object({
28296
+ id: zod.z.string(),
28297
+ firstname: zod.z.string().optional(),
28298
+ lastname: zod.z.string().optional(),
28299
+ email: zod.z.string().optional(),
28300
+ phone: zod.z.string().optional(),
28301
+ company: zod.z.string().optional(),
28302
+ createdAt: zod.z.string().optional(),
28303
+ updatedAt: zod.z.string().optional()
28304
+ });
28305
+ const searchContactsOutputSchema = zod.z.object({
28306
+ contacts: zod.z.array(ContactSchema),
28307
+ nextCursor: zod.z.string().optional()
28308
+ });
28309
+ function searchContactsTool(proxy) {
28310
+ return (0, _mastra_core_tools.createTool)({
28311
+ id: "hubspot_search_contacts",
28312
+ description: "Search contacts by free-text query or property filters instead of paging the full contact list.",
28313
+ inputSchema: searchContactsInputSchema,
28314
+ outputSchema: searchContactsOutputSchema,
28315
+ execute: async (input, { requestContext }) => {
28316
+ const platformProxy = proxy.withRequestContext(requestContext);
28317
+ const filters = [];
28318
+ if (input.email) filters.push({
28319
+ propertyName: "email",
28320
+ operator: "EQ",
28321
+ value: input.email
28322
+ });
28323
+ if (input.firstname) filters.push({
28324
+ propertyName: "firstname",
28325
+ operator: "CONTAINS_TOKEN",
28326
+ value: input.firstname
28327
+ });
28328
+ if (input.lastname) filters.push({
28329
+ propertyName: "lastname",
28330
+ operator: "CONTAINS_TOKEN",
28331
+ value: input.lastname
28332
+ });
28333
+ if (input.company) filters.push({
28334
+ propertyName: "company",
28335
+ operator: "CONTAINS_TOKEN",
28336
+ value: input.company
28337
+ });
28338
+ const searchBody = {
28339
+ properties: [
28340
+ "firstname",
28341
+ "lastname",
28342
+ "email",
28343
+ "phone",
28344
+ "company",
28345
+ "createdate",
28346
+ "lastmodifieddate"
28347
+ ],
28348
+ limit: 100
28349
+ };
28350
+ if (input.query) searchBody.query = input.query;
28351
+ if (filters.length > 0) searchBody.filterGroups = [{ filters }];
28352
+ if (input.cursor) searchBody.after = input.cursor;
28353
+ const data = (await platformProxy.post({
28354
+ endpoint: "/crm/v3/objects/contacts/search",
28355
+ data: searchBody,
28356
+ retries: 3
28357
+ })).data;
28358
+ return {
28359
+ contacts: (data.results || []).map((contact) => ({
28360
+ id: contact.id,
28361
+ firstname: contact.properties?.["firstname"] ?? void 0,
28362
+ lastname: contact.properties?.["lastname"] ?? void 0,
28363
+ email: contact.properties?.["email"] ?? void 0,
28364
+ phone: contact.properties?.["phone"] ?? void 0,
28365
+ company: contact.properties?.["company"] ?? void 0,
28366
+ createdAt: contact.properties?.["createdate"] ?? void 0,
28367
+ updatedAt: contact.properties?.["lastmodifieddate"] ?? void 0
28368
+ })),
28369
+ nextCursor: data.paging?.next?.after || void 0
28370
+ };
28371
+ }
28372
+ });
28373
+ }
28374
+ //#endregion
27956
28375
  //#region src/providers/hubspot/tools/search-deals.ts
27957
28376
  const searchDealsInputSchema = zod.z.object({
27958
28377
  query: zod.z.string().optional().describe("Search query to match against default searchable properties (dealname, pipeline, dealstage, description, dealtype)"),
@@ -28700,6 +29119,7 @@ function createHubspotTools(options) {
28700
29119
  hubspot_list_marketing_emails: listMarketingEmailsTool(platformProxy),
28701
29120
  hubspot_list_tickets: listTicketsTool(platformProxy),
28702
29121
  hubspot_search_companies: searchCompaniesTool(platformProxy),
29122
+ hubspot_search_contacts: searchContactsTool(platformProxy),
28703
29123
  hubspot_search_deals: searchDealsTool(platformProxy),
28704
29124
  hubspot_search_tickets: searchTicketsTool(platformProxy),
28705
29125
  hubspot_submit_form: submitFormTool(platformProxy),
@@ -60053,7 +60473,7 @@ function leaveChannelTool(proxy) {
60053
60473
  }
60054
60474
  //#endregion
60055
60475
  //#region src/providers/slack/tools/list-channels.ts
60056
- const ConversationSchema = zod.z.object({
60476
+ const ConversationSchema$1 = zod.z.object({
60057
60477
  id: zod.z.string(),
60058
60478
  name: zod.z.string(),
60059
60479
  created: zod.z.number(),
@@ -60071,7 +60491,7 @@ const listChannelsInputSchema = zod.z.object({
60071
60491
  limit: zod.z.number().optional().describe("Maximum number of conversations to return (1-200). Default: 100.")
60072
60492
  });
60073
60493
  const listChannelsOutputSchema = zod.z.object({
60074
- conversations: zod.z.array(ConversationSchema),
60494
+ conversations: zod.z.array(ConversationSchema$1),
60075
60495
  next_cursor: zod.z.string().optional(),
60076
60496
  total: zod.z.number()
60077
60497
  });
@@ -61002,6 +61422,122 @@ function scheduleMessageTool(proxy) {
61002
61422
  });
61003
61423
  }
61004
61424
  //#endregion
61425
+ //#region src/providers/slack/tools/search-channels.ts
61426
+ const ConversationSchema = zod.z.object({
61427
+ id: zod.z.string(),
61428
+ name: zod.z.string(),
61429
+ created: zod.z.number(),
61430
+ creator: zod.z.string(),
61431
+ is_archived: zod.z.boolean(),
61432
+ is_general: zod.z.boolean(),
61433
+ is_private: zod.z.boolean(),
61434
+ is_mpim: zod.z.boolean(),
61435
+ is_im: zod.z.boolean(),
61436
+ num_members: zod.z.number().optional()
61437
+ });
61438
+ const searchChannelsInputSchema = zod.z.object({
61439
+ query: zod.z.string().min(1).describe("Channel name to search for. Case-insensitive substring match; a leading # is ignored."),
61440
+ types: zod.z.string().optional().describe("Comma-separated list of conversation types to search. Options: public_channel, private_channel, mpim, im. Default: public_channel."),
61441
+ limit: zod.z.number().int().min(1).max(100).optional().describe("Maximum number of matching channels to return. Default: 20."),
61442
+ cursor: zod.z.string().optional().describe("Pagination cursor from a previous response to continue scanning. Omit to start from the beginning.")
61443
+ });
61444
+ const searchChannelsOutputSchema = zod.z.object({
61445
+ conversations: zod.z.array(ConversationSchema),
61446
+ total: zod.z.number(),
61447
+ next_cursor: zod.z.string().optional().describe("Present when the workspace was not fully scanned; pass back as cursor to continue searching.")
61448
+ });
61449
+ const PAGE_SIZE = 200;
61450
+ const MAX_PAGES_PER_CALL = 10;
61451
+ /**
61452
+ * The continuation cursor is either a raw Slack conversations.list cursor or,
61453
+ * when a call stopped mid-page because the match limit was reached, an
61454
+ * `offset:<n>:<slack cursor>` composite that re-fetches the same page and
61455
+ * resumes from channel index `<n>` so no matches are skipped.
61456
+ */
61457
+ function parseContinuationCursor(raw) {
61458
+ if (!raw) return {
61459
+ pageCursor: void 0,
61460
+ offset: 0
61461
+ };
61462
+ const match = /^offset:(\d+):(.*)$/.exec(raw);
61463
+ if (match) return {
61464
+ pageCursor: match[2] || void 0,
61465
+ offset: Number.parseInt(match[1], 10)
61466
+ };
61467
+ return {
61468
+ pageCursor: raw,
61469
+ offset: 0
61470
+ };
61471
+ }
61472
+ function searchChannelsTool(proxy) {
61473
+ return (0, _mastra_core_tools.createTool)({
61474
+ id: "slack_search_channels",
61475
+ description: "Find Slack channels by name without paging manually. Scans conversations.list and returns channels whose name contains the query (case-insensitive).",
61476
+ inputSchema: searchChannelsInputSchema,
61477
+ outputSchema: searchChannelsOutputSchema,
61478
+ execute: async (input, { requestContext }) => {
61479
+ const platformProxy = proxy.withRequestContext(requestContext);
61480
+ const query = input.query.replace(/^#/, "").toLowerCase();
61481
+ const maxMatches = input.limit ?? 20;
61482
+ const matches = [];
61483
+ let { pageCursor, offset } = parseContinuationCursor(input.cursor);
61484
+ let nextCursor;
61485
+ for (let page = 0; page < MAX_PAGES_PER_CALL; page++) {
61486
+ const config = {
61487
+ endpoint: "conversations.list",
61488
+ params: {
61489
+ types: input.types || "public_channel",
61490
+ limit: PAGE_SIZE,
61491
+ ...pageCursor && { cursor: pageCursor }
61492
+ },
61493
+ retries: 3
61494
+ };
61495
+ const response = await platformProxy.get(config);
61496
+ const channels = response.data.channels || [];
61497
+ const rawNextCursor = (response.data.response_metadata || {}).next_cursor || void 0;
61498
+ const slackNextCursor = rawNextCursor !== pageCursor ? rawNextCursor : void 0;
61499
+ for (let index = offset; index < channels.length; index++) {
61500
+ const channel = channels[index];
61501
+ const name = channel.name || "";
61502
+ if (!name.toLowerCase().includes(query)) continue;
61503
+ matches.push({
61504
+ id: channel.id,
61505
+ name,
61506
+ created: channel.created || 0,
61507
+ creator: channel.creator || "",
61508
+ is_archived: channel.is_archived || false,
61509
+ is_general: channel.is_general || false,
61510
+ is_private: channel.is_private || false,
61511
+ is_mpim: channel.is_mpim || false,
61512
+ is_im: channel.is_im || false,
61513
+ num_members: channel.num_members
61514
+ });
61515
+ if (matches.length >= maxMatches) {
61516
+ nextCursor = index + 1 < channels.length ? `offset:${index + 1}:${pageCursor ?? ""}` : slackNextCursor;
61517
+ return {
61518
+ conversations: matches,
61519
+ total: matches.length,
61520
+ ...nextCursor !== void 0 && { next_cursor: nextCursor }
61521
+ };
61522
+ }
61523
+ }
61524
+ offset = 0;
61525
+ if (!slackNextCursor) {
61526
+ nextCursor = void 0;
61527
+ break;
61528
+ }
61529
+ pageCursor = slackNextCursor;
61530
+ nextCursor = slackNextCursor;
61531
+ }
61532
+ return {
61533
+ conversations: matches,
61534
+ total: matches.length,
61535
+ ...nextCursor !== void 0 && { next_cursor: nextCursor }
61536
+ };
61537
+ }
61538
+ });
61539
+ }
61540
+ //#endregion
61005
61541
  //#region src/providers/slack/tools/search-files.ts
61006
61542
  const searchFilesInputSchema = zod.z.object({
61007
61543
  query: zod.z.string().describe("Search query string. Example: \"report\""),
@@ -61668,6 +62204,7 @@ function createSlackTools(options) {
61668
62204
  slack_remove_reaction: removeReactionTool(platformProxy),
61669
62205
  slack_rename_channel: renameChannelTool(platformProxy),
61670
62206
  slack_schedule_message: scheduleMessageTool(platformProxy),
62207
+ slack_search_channels: searchChannelsTool(platformProxy),
61671
62208
  slack_search_files: searchFilesTool(platformProxy),
61672
62209
  slack_search_messages: searchMessagesTool(platformProxy),
61673
62210
  slack_send_ephemeral_message: sendEphemeralMessageTool(platformProxy),
@@ -66300,7 +66837,7 @@ const listCustomersInputSchema = zod.z.object({
66300
66837
  created_after: zod.z.number().int().optional().describe("Only return customers that were created after this Unix timestamp. Maps to created[gte]."),
66301
66838
  created_before: zod.z.number().int().optional().describe("Only return customers that were created before this Unix timestamp. Maps to created[lte].")
66302
66839
  });
66303
- const CustomerSchema = zod.z.object({
66840
+ const CustomerSchema$1 = zod.z.object({
66304
66841
  id: zod.z.string(),
66305
66842
  object: zod.z.literal("customer"),
66306
66843
  address: zod.z.object({
@@ -66354,10 +66891,10 @@ const ListResponseSchema$1 = zod.z.object({
66354
66891
  object: zod.z.literal("list"),
66355
66892
  url: zod.z.string().optional(),
66356
66893
  has_more: zod.z.boolean(),
66357
- data: zod.z.array(CustomerSchema)
66894
+ data: zod.z.array(CustomerSchema$1)
66358
66895
  });
66359
66896
  const listCustomersOutputSchema = zod.z.object({
66360
- items: zod.z.array(CustomerSchema),
66897
+ items: zod.z.array(CustomerSchema$1),
66361
66898
  next_cursor: zod.z.string().optional()
66362
66899
  });
66363
66900
  function listCustomersTool(proxy) {
@@ -67240,6 +67777,63 @@ function retrieveBalanceTool(proxy) {
67240
67777
  });
67241
67778
  }
67242
67779
  //#endregion
67780
+ //#region src/providers/stripe/tools/search-customers.ts
67781
+ const searchCustomersInputSchema = zod.z.object({
67782
+ query: zod.z.string().min(1).describe("Stripe search query. Supports field-scoped clauses like email:\"jane@example.com\", name~\"jane\" (substring), or metadata[\"key\"]:\"value\". See https://stripe.com/docs/search#search-query-language."),
67783
+ limit: zod.z.number().int().min(1).max(100).optional().describe("A limit on the number of objects to be returned. Between 1 and 100, default 10."),
67784
+ cursor: zod.z.string().optional().describe("Pagination cursor from the previous response. Maps to Stripe's page parameter. Omit for first page.")
67785
+ });
67786
+ const CustomerSchema = zod.z.object({
67787
+ id: zod.z.string(),
67788
+ email: zod.z.string().nullable().optional(),
67789
+ name: zod.z.string().nullable().optional(),
67790
+ description: zod.z.string().nullable().optional(),
67791
+ created: zod.z.number().optional(),
67792
+ currency: zod.z.string().nullable().optional(),
67793
+ delinquent: zod.z.boolean().nullable().optional(),
67794
+ livemode: zod.z.boolean().optional(),
67795
+ metadata: zod.z.record(zod.z.string(), zod.z.string()).optional()
67796
+ });
67797
+ const searchCustomersOutputSchema = zod.z.object({
67798
+ customers: zod.z.array(CustomerSchema),
67799
+ next_cursor: zod.z.string().optional(),
67800
+ total_count: zod.z.number().optional()
67801
+ });
67802
+ function searchCustomersTool(proxy) {
67803
+ return (0, _mastra_core_tools.createTool)({
67804
+ id: "stripe_search_customers",
67805
+ description: "Search Stripe customers by email, name, or metadata using Stripe's search query language instead of paging the full customer list. New customers can take up to a minute to become searchable.",
67806
+ inputSchema: searchCustomersInputSchema,
67807
+ outputSchema: searchCustomersOutputSchema,
67808
+ execute: async (input, { requestContext }) => {
67809
+ const data = (await proxy.withRequestContext(requestContext).get({
67810
+ endpoint: "/v1/customers/search",
67811
+ params: {
67812
+ query: input.query,
67813
+ ...input.limit !== void 0 && { limit: String(input.limit) },
67814
+ ...input.cursor !== void 0 && { page: input.cursor }
67815
+ },
67816
+ retries: 3
67817
+ })).data;
67818
+ return {
67819
+ customers: (data.data || []).map((customer) => ({
67820
+ id: customer.id,
67821
+ email: customer.email ?? void 0,
67822
+ name: customer.name ?? void 0,
67823
+ description: customer.description ?? void 0,
67824
+ created: customer.created,
67825
+ currency: customer.currency ?? void 0,
67826
+ delinquent: customer.delinquent ?? void 0,
67827
+ livemode: customer.livemode,
67828
+ metadata: customer.metadata
67829
+ })),
67830
+ ...data.has_more && data.next_page && { next_cursor: data.next_page },
67831
+ ...data.total_count !== void 0 && { total_count: data.total_count }
67832
+ };
67833
+ }
67834
+ });
67835
+ }
67836
+ //#endregion
67243
67837
  //#region src/providers/stripe/tools/update-customer.ts
67244
67838
  const updateCustomerInputSchema = zod.z.object({
67245
67839
  id: zod.z.string().describe("The ID of the customer to update. Example: cus_123"),
@@ -68366,6 +68960,7 @@ function createStripeTools(options) {
68366
68960
  stripe_list_setup_intents: listSetupIntentsTool(platformProxy),
68367
68961
  stripe_list_subscriptions: listSubscriptionsTool(platformProxy),
68368
68962
  stripe_retrieve_balance: retrieveBalanceTool(platformProxy),
68963
+ stripe_search_customers: searchCustomersTool(platformProxy),
68369
68964
  stripe_update_customer: updateCustomerTool(platformProxy),
68370
68965
  stripe_update_invoice_item: updateInvoiceItemTool(platformProxy),
68371
68966
  stripe_update_invoice: updateInvoiceTool(platformProxy),