@knocklabs/agent-toolkit 0.4.0 → 0.5.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.
@@ -5,11 +5,11 @@ import {
5
5
  } from "../chunk-X3LAGKQW.js";
6
6
  import {
7
7
  createKnockClient
8
- } from "../chunk-PLL3H2Y6.js";
8
+ } from "../chunk-UBRPLPCX.js";
9
9
  import {
10
10
  getToolMap,
11
11
  getToolsByPermissionsInCategories
12
- } from "../chunk-WSJ5XINN.js";
12
+ } from "../chunk-3Q6IG57F.js";
13
13
  import "../chunk-G3PMV62Z.js";
14
14
 
15
15
  // src/ai-sdk/tool-converter.ts
@@ -1178,7 +1178,7 @@ var createOrUpdateUser = KnockTool({
1178
1178
  }),
1179
1179
  execute: (knockClient, config) => async (params) => {
1180
1180
  const publicClient = await knockClient.publicApi(params.environment);
1181
- const user = await publicClient.users.identify(
1181
+ const user = await publicClient.users.update(
1182
1182
  params.userId ?? config.userId,
1183
1183
  {
1184
1184
  email: params.email,
@@ -2133,4 +2133,4 @@ export {
2133
2133
  getToolsByPermissionsInCategories,
2134
2134
  getToolMap
2135
2135
  };
2136
- //# sourceMappingURL=chunk-WSJ5XINN.js.map
2136
+ //# sourceMappingURL=chunk-3Q6IG57F.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/knock-tool.ts","../src/lib/tools/channels.ts","../src/lib/tools/commits.ts","../src/lib/tools/documentation.ts","../src/lib/tools/email-layouts.ts","../src/lib/tools/environments.ts","../src/lib/tools/guides.ts","../src/lib/tools/shared.ts","../src/lib/tools/message-types.ts","../src/lib/tools/messages.ts","../src/lib/tools/objects.ts","../src/lib/tools/partials.ts","../src/lib/tools/tenants.ts","../src/lib/tools/users.ts","../src/lib/tools/workflows-as-tools.ts","../src/lib/utils.ts","../src/lib/tools/workflows.ts","../src/lib/tools/workflow-steps.ts","../src/lib/tools/index.ts"],"sourcesContent":["import type { ZodObject } from \"zod\";\nimport { z } from \"zod\";\n\nimport { Config } from \"../types.js\";\n\nimport { KnockClient } from \"./knock-client.js\";\n\nexport interface KnockToolDefinition {\n /**\n * The method name of the tool. This is a machine-readable string.\n */\n method: string;\n /**\n * The name of the tool. This can be used to reference the tool in the code.\n * A descriptive LLM-readable string.\n */\n name: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, including examples where useful.\n */\n description: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, usage and input parameters.\n * Ths is intended to be used by the underlying LLM.\n */\n fullDescription: string;\n\n /**\n * The Zod schema for the input parameters of the tool\n */\n parameters?: ZodObject<any>;\n /**\n * The actual implementation of the tool.\n */\n execute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nexport interface KnockTool extends Omit<KnockToolDefinition, \"execute\"> {\n bindExecute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nconst trimLines = (text: string) =>\n text\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter(Boolean)\n .join(\"\\n\");\n\nexport const KnockTool = (\n args: Omit<KnockToolDefinition, \"fullDescription\">\n): KnockTool => {\n const { execute, ...restOfArgs } = args;\n const parameters = restOfArgs.parameters\n ? restOfArgs.parameters\n : z.object({});\n\n const schemaEntries = Object.entries(parameters.shape);\n\n const argsStr =\n schemaEntries.length === 0\n ? \"Takes no arguments\"\n : schemaEntries\n .map(([key, value]) => {\n return `- ${key}: ${(value as any).description || \"\"}`;\n })\n .join(\"\\n\");\n\n const fullDescription = trimLines(`\n Tool name:\n ${args.name}\n Description:\n ${args.description}.\n Arguments:\n ${argsStr}\n `);\n\n return {\n ...restOfArgs,\n parameters,\n fullDescription,\n bindExecute:\n (knockClient: KnockClient, config: Config) => async (input: any) => {\n try {\n return await execute(knockClient, config)(input);\n } catch (error: unknown) {\n console.error(error);\n\n if (error instanceof Error) {\n return {\n message: `An error occurred with the call to the Knock API: ${error.message}`,\n error,\n };\n }\n\n return {\n message:\n \"An unknown error occurred with the call to the Knock API.\",\n error,\n };\n }\n },\n };\n};\n","import { Channel } from \"@knocklabs/mgmt/resources/channels.js\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the Channel resource that is easier to work with in the LLM.\n */\ntype SerializedChannel = {\n key: string;\n name: string;\n type: string;\n provider: string;\n};\n\nfunction serializeChannelResponse(channel: Channel): SerializedChannel {\n return {\n key: channel.key,\n name: channel.name,\n type: channel.type,\n provider: channel.provider,\n };\n}\n\nconst listChannels = KnockTool({\n method: \"list_channels\",\n name: \"List channels\",\n description: `\n Returns a list of all of the channels configured in the account. Each channel returns information about the type of channel it is (email, sms, push, etc), and the provider that's used to power the channel. Channels can be used across all environments.\n\n Use this tool when you need to know about the channels configured in the Knock account, like when configuring a workflow.\n `,\n execute: (knockClient) => async (_params) => {\n const allChannels: SerializedChannel[] = [];\n for await (const channel of knockClient.channels.list()) {\n allChannels.push(serializeChannelResponse(channel));\n }\n return allChannels;\n },\n});\n\nexport const channels = {\n listChannels,\n};\n\nexport const permissions = {\n read: [\"listChannels\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listCommits = KnockTool({\n method: \"list_commits\",\n name: \"List commits\",\n description: `\n Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list commits for. Defaults to `development`.\"\n ),\n promoted: z\n .boolean()\n .describe(\n \"(boolean): Whether to only return promoted commits. Defaults to `false`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.list({\n environment: params.environment ?? config.environment ?? \"development\",\n promoted: params.promoted ?? false,\n });\n },\n});\n\nconst commitAllChanges = KnockTool({\n method: \"commit_all_changes\",\n name: \"Commit all changes\",\n description: `\n Commit all pending changes. This can only be used in the development environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to commit all changes to. Defaults to `development`.\"\n ),\n message: z\n .string()\n .optional()\n .describe(\"(string): The message to include in the commit.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.commitAll({\n environment: params.environment ?? config.environment ?? \"development\",\n commit_message: params.message,\n });\n },\n});\n\nconst promoteAllCommits = KnockTool({\n method: \"promote_all_commits\",\n name: \"Promote all commits\",\n description: `\n Promote all commits to the next environment. Use this tool when you are asked to deploy all changes.\n `,\n parameters: z.object({\n toEnvironment: z\n .string()\n .describe(\"(string): The environment to promote all commits to.\"),\n }),\n execute: (knockClient, _config) => async (params) => {\n return await knockClient.put(\"/v1/commits/promote\", {\n body: { to_environment: params.toEnvironment },\n });\n },\n});\n\nexport const commits = {\n listCommits,\n commitAllChanges,\n promoteAllCommits,\n};\n\nexport const permissions = {\n read: [\"listCommits\"],\n manage: [\"commitAllChanges\", \"promoteAllCommits\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst searchDocumentation = KnockTool({\n method: \"search_documentation\",\n name: \"Search documentation\",\n description: \"Search the Knock documentation for a given query\",\n parameters: z.object({\n query: z.string().describe(\"The query to search the documentation for\"),\n }),\n execute: () => async (params) => {\n const response = await fetch(`https://docs.knock.app/api/search`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ query: params.query }),\n });\n\n const data = await response.json();\n return data;\n },\n});\n\nexport const documentation = {\n searchDocumentation,\n};\n\nexport const permissions = {\n read: [\"searchDocumentation\"],\n};\n","import { EmailLayout } from \"@knocklabs/mgmt/resources/email-layouts.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the EmailLayout resource that is easier to work with in the LLM.\n */\ntype SerializedEmailLayout = {\n key: string;\n name: string;\n htmlContent: string;\n textContent: string;\n};\n\nfunction serializeEmailLayoutResponse(\n emailLayout: EmailLayout\n): SerializedEmailLayout {\n return {\n key: emailLayout.key,\n name: emailLayout.name,\n htmlContent: emailLayout.html_layout,\n textContent: emailLayout.text_layout,\n };\n}\n\nconst listEmailLayouts = KnockTool({\n method: \"list_email_layouts\",\n name: \"List email layouts\",\n description: `List all email layouts within the environment given. Returns information about the email layout, including the name and the key. \n \n Use this tool when building a workflow that is building an email notification when you need to know the available email layouts.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list email layouts for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allEmailLayouts: SerializedEmailLayout[] = [];\n for await (const emailLayout of knockClient.emailLayouts.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allEmailLayouts.push(serializeEmailLayoutResponse(emailLayout));\n }\n return allEmailLayouts;\n },\n});\n\nconst createOrUpdateEmailLayout = KnockTool({\n method: \"upsert_email_layout\",\n name: \"Create or update email layout\",\n description: `Create or update a new email layout within the environment given. Use this tool when you need to define shared pieces of content across multiple email templates, like a header/footer. The email layout will be used to render the email template.\n\n Here are the rules for creating an email layout:\n\n - Every email layout must have a \\`{{ content }}\\` tag. This is where the content of the email will be injected.\n - You must set both an HTML and text version of the email layout.\n - CSS should be included in the HTML version of the email layout under <style> tags.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the email layout for. Defaults to `development`.\"\n ),\n key: z\n .string()\n .describe(\"(string): The key of the email layout to create or update.\"),\n name: z.string().describe(\"(string): The name of the email layout.\"),\n htmlContent: z\n .string()\n .describe(\"(string): The HTML content of the email layout.\"),\n textContent: z\n .string()\n .describe(\"(string): The text content of the email layout.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const response = await knockClient.emailLayouts.upsert(params.key, {\n environment: params.environment ?? config.environment ?? \"development\",\n email_layout: {\n name: params.name,\n html_layout: params.htmlContent,\n text_layout: params.textContent,\n },\n });\n\n return serializeEmailLayoutResponse(response.email_layout);\n },\n});\n\nexport const emailLayouts = {\n listEmailLayouts,\n createOrUpdateEmailLayout,\n};\n\nexport const permissions = {\n read: [\"listEmailLayouts\"],\n manage: [\"createOrUpdateEmailLayout\"],\n};\n","import { Environment } from \"@knocklabs/mgmt/resources/environments.js\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the Environment resource that is easier to work with in the LLM.\n */\ntype SerializedEnvironment = {\n slug: string;\n name: string;\n};\n\nfunction serializeEnvironmentResponse(\n environment: Environment\n): SerializedEnvironment {\n return {\n slug: environment.slug,\n name: environment.name,\n };\n}\n\nconst listEnvironments = KnockTool({\n method: \"list_environments\",\n name: \"List environments\",\n description: `\n Lists all environments available, returning the slug and name of each environment. Use this tool when you need to see what environments are available.\n `,\n execute: (knockClient) => async (_params) => {\n const allEnvironments: SerializedEnvironment[] = [];\n for await (const environment of knockClient.environments.list()) {\n allEnvironments.push(serializeEnvironmentResponse(environment));\n }\n return allEnvironments;\n },\n});\n\nexport const environments = {\n listEnvironments,\n};\n\nexport const permissions = {\n read: [\"listEnvironments\"],\n};\n","import { Guide } from \"@knocklabs/mgmt/resources.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nimport { conditionSchema } from \"./shared.js\";\n\n/**\n * A slimmed down version of the Guide resource that is easier to work with in the LLM.\n */\ntype SerializedGuide = Pick<\n Guide,\n \"key\" | \"name\" | \"description\" | \"type\" | \"active\"\n> & {\n steps: {\n ref: string;\n name: string;\n schemaKey: string;\n schemaVariantKey: string;\n schemaContent?: Record<string, any>;\n }[];\n};\n\nfunction serializeGuide(guide: Guide): SerializedGuide {\n return {\n key: guide.key,\n name: guide.name,\n description: guide.description,\n type: guide.type,\n active: guide.active,\n steps: (guide.steps ?? []).map((step) => ({\n ref: step.ref,\n name: step.name!,\n schemaKey: step.schema_key,\n schemaVariantKey: step.schema_variant_key,\n schemaContent: step.values,\n })),\n };\n}\n\nconst listGuides = KnockTool({\n method: \"list_guides\",\n name: \"List guides\",\n description: `\n List all guides available for the given environment. Returns structural information about the guides, including the key, name, description, type, and status.\n\n Use this tool when you need to understand which guides are available in the environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list guides for. Defaults to `development`.\"\n ),\n page_size: z\n .number()\n .optional()\n .describe(\"(number): The number of guides to return per page.\"),\n after: z\n .string()\n .optional()\n .describe(\"(string): The cursor to use for pagination.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const allGuides: SerializedGuide[] = [];\n const listParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n page_size: params.page_size,\n after: params.after,\n };\n for await (const guide of knockClient.guides.list(listParams)) {\n allGuides.push(serializeGuide(guide));\n }\n return allGuides;\n },\n});\n\nconst getGuide = KnockTool({\n method: \"get_guide\",\n name: \"Get guide\",\n description: `\n Get a guide by its key. Returns structural information about the guide, including the key, name, description, type, and status.\n\n Use this tool when you need to retrieve information about a specific guide.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the guide for. Defaults to `development`.\"\n ),\n guideKey: z.string().describe(\"(string): The key of the guide to get.\"),\n hide_uncommitted_changes: z\n .boolean()\n .optional()\n .describe(\n \"(boolean): Whether to hide uncommitted changes and return only published version.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const guide = await knockClient.guides.retrieve(params.guideKey, {\n environment: params.environment ?? config.environment ?? \"development\",\n hide_uncommitted_changes: params.hide_uncommitted_changes,\n });\n return serializeGuide(guide);\n },\n});\n\nconst createOrUpdateGuide = KnockTool({\n method: \"upsert_guide\",\n name: \"Upsert guide\",\n description: `\n Create or update a guide. A guide defines an in-app guide that can be displayed to users based on priority and other conditions.\n\n Use this tool when you need to create a new guide or update an existing one. The guide will be created with the specified configuration.\n\n Note: This endpoint only operates on guides in the \"development\" environment.\n\n ## Guide step schema\n\n When working with guide steps, you must use a \\`schemaKey\\` and \\`schemaVariantKey\\` to reference the message type schema that the step's content conforms to. You can use the \\`list_message_types\\` tool to get a list of available message types and the available variants for that message type.\n\n You **must** supply a \\`schemaContent\\` that sets the content for each of the fields in the \\`fields\\` object inside of the message type schema variant you select.\n \n For example, if you have a message type schema with a \\`fields\\` object that looks like this:\n\n \\`\\`\\`json\n {\n \"fields\": {\n \"title\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n }\n \\`\\`\\`\n\n You would need to supply a \\`schemaContent\\` that looks like this:\n\n \\`\\`\\`json\n {\n \"title\": \"Hello, world!\"\n }\n \\`\\`\\`\n\n ### Guide targeting\n\n By default, a guide will target all users. If you want to target users with specific attributes, you can use \\`targetPropertyConditions\\` to describe the targeting conditions.\n\n When using targeting conditions, you can use the following properties:\n\n - \\`recipient\\`: Use a property on the recipient\n - \\`data\\`: Use data coming from the application\n - \\`tenant\\`: Use a property on the tenant\n\n For example, if you want to target users with the email \\`john.doe@example.com\\`, you would supply the following targeting conditions:\n\n \\`\\`\\`json\n [\n { \"operator\": \"equal_to\", \"value\": \"john.doe@example.com\", \"argument\": \"recipient.email\" }\n ]\n \\`\\`\\`\n\n ### Activation location rules\n\n You can supply a list of activation location rules to describe where in your application the guide should be shown. Each activation rule is a directive that describes whether the guide should be shown or hidden based on the pathname of the page.\n\n For example, if you want to show the guide on all pages except for the \\`admin\\` path, you would supply the following activation location rules:\n\n \\`\\`\\`json\n [\n { \"directive\": \"allow\", \"pathname\": \"*\" },\n { \"directive\": \"block\", \"pathname\": \"/admin\" }\n ]\n \\`\\`\\`\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to upsert the guide for. Defaults to `development`.\"\n ),\n guideKey: z\n .string()\n .describe(\n \"(string): The key of the guide to upsert. Must be at minimum 3 characters and at maximum 255 characters in length. Must be in the format of ^[a-z0-9_-]+$.\"\n ),\n name: z\n .string()\n .describe(\n \"(string): A name for the guide. Must be at maximum 255 characters in length.\"\n ),\n channelKey: z\n .string()\n .optional()\n .describe(\n \"(string): The key of the channel in which the guide exists. Defaults to `knock-guide`.\"\n )\n .default(\"knock-guide\"),\n description: z\n .string()\n .optional()\n .describe(\n \"(string): An arbitrary string attached to a guide object. Maximum of 280 characters allowed.\"\n ),\n step: z\n .object({\n name: z\n .string()\n .describe(\"(string): The name of the step.\")\n .optional()\n .default(\"Default\"),\n ref: z\n .string()\n .describe(\"(string): The unique identifier of the step.\")\n .optional()\n .default(\"default\"),\n schemaKey: z\n .string()\n .describe(\n \"(string): The key of the schema that the step's content conforms to.\"\n ),\n schemaVariantKey: z\n .string()\n .describe(\n \"(string): The key of the schema variant that the step's content conforms to.\"\n )\n .optional()\n .default(\"default\"),\n schemaContent: z\n .record(z.string(), z.any())\n .describe(\n \"(object): A map of values that make up the step's content. Each value must conform to its respective template schema field settings.\"\n ),\n })\n .describe(\"(object): The guide step to upsert.\"),\n targetPropertyConditions: z\n .array(conditionSchema)\n .describe(\n \"(array): A list of property conditions that describe the target audience for the guide. Conditions are joined as AND operations.\"\n ),\n activationLocationRules: z\n .array(\n z.object({\n directive: z\n .enum([\"allow\", \"block\"])\n .describe(\n \"(string): The directive to apply to the activation location rule (allow or block).\"\n ),\n pathname: z\n .string()\n .describe(\n \"(string): The pathname to target. Should correspond to a URI in your application.\"\n ),\n })\n )\n .describe(\n \"(array): A list of activation location rules that describe where in your application the guide should be shown.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n // Attempt to fetch the message type to ensure it exists\n const messageType = await knockClient.messageTypes.retrieve(\n params.step.schemaKey,\n {\n environment: params.environment ?? config.environment ?? \"development\",\n }\n );\n\n // Ensure that the schema variant exists\n const schemaVariant = messageType.variants.find(\n (variant) => variant.key === params.step.schemaVariantKey\n );\n\n if (!schemaVariant) {\n throw new Error(\n `Schema variant ${params.step.schemaVariantKey} not found in message type ${messageType.key}`\n );\n }\n\n const result = await knockClient.guides.upsert(params.guideKey, {\n environment: params.environment ?? config.environment ?? \"development\",\n guide: {\n name: params.name,\n description: params.description,\n channel_key: params.channelKey ?? \"knock-guide\",\n steps: [\n {\n ref: params.step.ref ?? \"default\",\n schema_key: messageType.key,\n schema_semver: messageType.semver,\n schema_variant_key: schemaVariant.key,\n values: params.step.schemaContent,\n },\n ],\n target_property_conditions: {\n all: params.targetPropertyConditions,\n },\n activation_location_rules: params.activationLocationRules,\n },\n });\n\n return serializeGuide(result.guide);\n },\n});\n\nexport const guides = {\n listGuides,\n getGuide,\n createOrUpdateGuide,\n};\n\nexport const permissions = {\n read: [\"listGuides\", \"getGuide\"],\n manage: [\"createOrUpdateGuide\"],\n};\n","import { z } from \"zod\";\n\nconst recipientSchema = z\n .union([\n z.string().describe(\"A user ID (string).\"),\n z\n .object({ id: z.string(), collection: z.string() })\n .describe(\"A reference to an object in a collection.\"),\n ])\n .describe(\n \"A recipient can be a user ID or a reference to an object in a collection.\"\n );\n\nconst conditionSchema = z\n .object({\n operator: z\n .enum([\n \"equal_to\",\n \"not_equal_to\",\n \"greater_than\",\n \"less_than\",\n \"greater_than_or_equal_to\",\n \"less_than_or_equal_to\",\n \"contains\",\n \"not_contains\",\n \"contains_all\",\n \"empty\",\n \"not_empty\",\n ])\n .describe(\"(string): The operator to apply to the argument.\"),\n value: z.any().describe(\"(any): The value of the condition.\"),\n argument: z\n .string()\n .optional()\n .describe(\n \"(string): The argument of the condition. Can be empty when using empty or not_empty operators.\"\n ),\n })\n .describe(\"(object): A condition.\");\n\nexport { conditionSchema, recipientSchema };\n","import { MessageType } from \"@knocklabs/mgmt/resources/message-types.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the MessageType resource that is easier to work with in the LLM.\n */\ntype SerializedMessageType = {\n key: string;\n name: string;\n description?: string | null;\n variants: string[];\n};\n\nfunction serializeMessageTypeResponse(\n messageType: MessageType\n): SerializedMessageType {\n return {\n key: messageType.key,\n name: messageType.name,\n description: messageType.description,\n variants: messageType.variants.map((variant) => variant.key),\n };\n}\nconst listMessageTypes = KnockTool({\n method: \"list_message_types\",\n name: \"List message types\",\n description:\n \"List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list message types for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allMessageTypes: SerializedMessageType[] = [];\n for await (const messageType of knockClient.messageTypes.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allMessageTypes.push(serializeMessageTypeResponse(messageType));\n }\n return allMessageTypes;\n },\n});\n\nconst createOrUpdateMessageType = KnockTool({\n method: \"upsert_message_type\",\n name: \"Create or update message type\",\n description: `\n Create or update a message type. A message type is a schema that defines fields available to an editor within Knock. Message types always have at least one variant, that MUST be named \"default\". Use this tool when you need to create a new message type, or update an existing message type.\n\n ## Schema and fields\n\n The schema defines the fields available to an editor within Knock. A variant should have at least one field. Fields can be of different types, including: text, markdown, select, multi-select, image, and button.\n\n Each field must have a key, label, and type. Some fields like \\`select\\` and \\`multi_select\\` have additional settings that can be used to configure the field.\n\n <example>\n {\n \"key\": \"text\",\n \"label\": \"Text\",\n \"type\": \"text\",\n </example>\n\n <example>\n {\n \"key\": \"select\",\n \"label\": \"Select\",\n \"type\": \"select\",\n \"settings\": {\n \"options\": [\n {\n \"value\": \"option1\",\n \"label\": \"Option 1\",\n },\n ],\n },\n }\n </example>\n\n ## Preview templates\n\n The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named \"text\" will be rendered as {{ text }}. All fields should be included in the preview.\n\n You can make an educated guess as to what the preview template should look like based on the name of the message type and the fields. You can use plain CSS to style the preview by supplying a style tag in the preview. Use simple selectors like .class-name to style elements.\n\n <example>\n {\n \"preview\": \"<style>div { color: red; }</style>\\n<div>Hello there, {{ text }}</div>\"\n }\n </example>\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the message type in. Defaults to `development`.\"\n ),\n messageTypeKey: z\n .string()\n .describe(\"(string): The key of the message type to create or update.\"),\n name: z.string().describe(\"(string): The name of the message type.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the message type.\"),\n preview: z\n .string()\n .optional()\n .describe(\n \"(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants.\"\n ),\n variants: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the variant.\"),\n name: z.string().describe(\"(string): The name of the variant.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the variant.\"),\n fields: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the field.\"),\n type: z\n .string()\n .describe(\n \"(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`, `image`.\"\n ),\n label: z.string().describe(\"(string): The label of the field.\"),\n settings: z\n .object({})\n .optional()\n .describe(\"(object): The settings of the field.\"),\n })\n )\n .describe(\"(array): The fields of the variant.\"),\n })\n )\n .describe(\"(array): The variants of the message type.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.messageTypes.upsert(params.messageTypeKey, {\n message_type: {\n name: params.name,\n variants: params.variants,\n description: params.description ?? \"\",\n preview: params.preview ?? \"<div></div>\",\n },\n environment: params.environment ?? config.environment ?? \"development\",\n });\n },\n});\n\nexport const messageTypes = {\n listMessageTypes,\n createOrUpdateMessageType,\n};\n\nexport const permissions = {\n read: [\"listMessageTypes\"],\n manage: [\"createOrUpdateMessageType\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getMessageContent = KnockTool({\n method: \"get_message_content\",\n name: \"Get message content\",\n description: `\n Retrieves the complete contents of a single message, specified by the messageId. The message contents includes the rendered template that was sent to the recipient. Use this tool when you want to surface information about the emails, SMS, and push notifications that were sent to a user.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the message from. Defaults to `development`.\"\n ),\n messageId: z\n .string()\n .describe(\"(string): The messageId of the message to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.messages.getContent(params.messageId);\n },\n});\n\nexport const messages = {\n getMessageContent,\n};\n\nexport const permissions = {\n read: [\"getMessageContent\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listObjects = KnockTool({\n method: \"list_objects\",\n name: \"List objects\",\n description:\n \"List all objects in a single collection. Objects are used to model custom collections in Knock that are NOT users or tenants. Use this tool when you need to return a paginated list of objects in a single collection.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list objects from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to list objects from.\"),\n }),\n execute: (knockClient, _config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.list(params.collection);\n },\n});\n\nconst getObject = KnockTool({\n method: \"get_object\",\n name: \"Get object\",\n description:\n \"Get an object wihin a collection. Returns information about the object including any custom properties. Use this tool when you need to retrieve an object to understand it's properties.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the object from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to get the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to get.\"),\n }),\n execute: (knockClient, _config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.get(params.collection, params.objectId);\n },\n});\n\nconst createOrUpdateObject = KnockTool({\n method: \"upsert_object\",\n name: \"Create or update object\",\n description: `Create or update an object in a specific collection. Objects are used to model custom collections in Knock that are NOT users or tenants. If the object does not exist, it will be created. If the object exists, it will be updated with the provided properties. The update will always perform an upsert operation, so you do not need to provide the full properties each time.\n \n Use this tool when you need to create a new object, or update an existing custom-object. Custom objects can be used to subscribe users' to as lists, and also send non-user facing notifications to.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the object in. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to create or update the object in.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to create or update.\"),\n properties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): The properties to set on the object.\"),\n }),\n execute: (knockClient, _config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.set(\n params.collection,\n params.objectId,\n params.properties\n );\n },\n});\n\nconst subscribeUsersToObject = KnockTool({\n method: \"subscribe_users_to_object\",\n name: \"Subscribe users to object\",\n description: `\n Subscribe a list of users to an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to subscribe one or more users to an object where you will then trigger workflows for those lists of users to send notifications to.\n\n Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to subscribe the user to. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to subscribe the user to.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to subscribe the user to.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.addSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nconst unsubscribeUsersFromObject = KnockTool({\n method: \"unsubscribe_users_from_object\",\n name: \"Unsubscribe users from object\",\n description: `Unsubscribe a list of users from an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to unsubscribe one or more users from an object where you will then trigger workflows for those lists of users to send notifications to.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to unsubscribe the user from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to unsubscribe the user from.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to unsubscribe the user from.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to unsubscribe from the object.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.deleteSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nexport const objects = {\n listObjects,\n getObject,\n createOrUpdateObject,\n subscribeUsersToObject,\n unsubscribeUsersFromObject,\n};\n\nexport const permissions = {\n read: [\"listObjects\", \"getObject\"],\n manage: [\n \"createOrUpdateObject\",\n \"subscribeUsersToObject\",\n \"unsubscribeUsersFromObject\",\n ],\n};\n","import { Partial } from \"@knocklabs/mgmt/resources/partials.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"@/lib/knock-tool.js\";\n\n/**\n * A slimmed down version of the Partial resource that is easier to work with in the LLM.\n */\ntype SerializedPartial = {\n key: string;\n type: Partial[\"type\"];\n name: string;\n description?: string;\n};\n\nfunction serializePartial(partial: Partial): SerializedPartial {\n return {\n key: partial.key,\n type: partial.type,\n name: partial.name,\n description: partial.description,\n };\n}\n\nconst listPartials = KnockTool({\n method: \"list_partials\",\n name: \"List partials\",\n description: `\n List all partials within the environment given. Partials provide common building blocks for notification templates. Returns information about the partial, including the name and the key. \n Use this tool when you need to know the available partials for the environment, like when building a notification template and wanting to use a partial to build the template.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list partials for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allPartials: SerializedPartial[] = [];\n for await (const partial of knockClient.partials.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allPartials.push(serializePartial(partial));\n }\n return allPartials;\n },\n});\n\nconst getPartial = KnockTool({\n method: \"get_partial\",\n name: \"Get partial\",\n description: `\n Get a partial by its key. Use this tool when you need to know if a specific partial exists by key.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the partial for. Defaults to `development`.\"\n ),\n key: z.string().describe(\"(string): The key of the partial to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const partial = await knockClient.partials.retrieve(params.key, {\n environment: params.environment ?? config.environment ?? \"development\",\n });\n\n return serializePartial(partial);\n },\n});\n\nconst createOrUpdatePartial = KnockTool({\n method: \"upsert_partial\",\n name: \"Upsert partial\",\n description: `\n Create or update a partial. A partial is a reusable piece of content that can be used in a template. Use this tool when you need to create a new partial or update an existing one.\n\n When working with a partial you must chose the type of the partial. The type determines the format of the content. If you're working with an email template, you should use the \"html\" or \"markdown\" type.\n\n If you need to work with dynamic content in your partial you can use liquid syntax. Liquid is a templating language that is supported in Knock. You can supply a variable like {{ some_variable }} in the content and it will be replaced with the actual value when the partial is used in a template.\n\n <example>\n {\n \"name\": \"Greeting\",\n \"key\": \"greeting\",\n \"type\": \"html\",\n \"content\": \"<div>Hello, {{ recipient_name }}</div>\"\n }\n </example>\n\n Changes to a partial MUST be committed before they can be used in a template.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to upsert the partial for. Defaults to `development`.\"\n ),\n key: z.string().describe(\"(string): The key of the partial to upsert.\"),\n name: z.string().describe(\"(string): The name of the partial.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the partial.\"),\n content: z.string().describe(\"(string): The content of the partial.\"),\n type: z\n .enum([\"html\", \"text\", \"json\", \"markdown\"])\n .describe(\"(string): The type of the partial.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const partial = await knockClient.partials.upsert(params.key, {\n environment: params.environment ?? config.environment ?? \"development\",\n partial: {\n name: params.name,\n description: params.description,\n content: params.content,\n type: params.type,\n },\n });\n return serializePartial(partial.partial);\n },\n});\n\nexport const partials = {\n getPartial,\n listPartials,\n createOrUpdatePartial,\n};\n\nexport const permissions = {\n read: [\"getPartial\", \"listPartials\"],\n manage: [\"createOrUpdatePartial\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getTenant = KnockTool({\n method: \"get_tenant\",\n name: \"Get tenant\",\n description: `\n Retrieves a tenant by their ID. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.\n \n Use this tool when you need to lookup the information about a tenant, including name, and if there are any custom properties set.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the tenant from. Defaults to `development`.\"\n ),\n tenantId: z\n .string()\n .describe(\"(string): The ID of the tenant to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.get(params.tenantId);\n },\n});\n\nconst listTenants = KnockTool({\n method: \"list_tenants\",\n name: \"List tenants\",\n description: `\n Retrieves a list of tenants. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object. \n \n Use this tool when you need to list all tenants in an environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the tenants from. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.list();\n },\n});\n\nconst createOrUpdateTenant = KnockTool({\n method: \"upsert_tenant\",\n name: \"Create or update tenant\",\n description: `\n Creates or updates a tenant using the properties provided. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.\n \n Use this tool when you need to create a new tenant, or update an existing tenant's properties.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to set the tenant in. Defaults to `development`.\"\n ),\n tenantId: z.string().describe(\"(string): The ID of the tenant to update.\"),\n name: z.string().optional().describe(\"(string): The name of the tenant.\"),\n properties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): The properties to set on the tenant.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.set(params.tenantId, {\n name: params.name,\n ...params.properties,\n });\n },\n});\n\nexport const tenants = {\n getTenant,\n listTenants,\n createOrUpdateTenant,\n};\n\nexport const permissions = {\n read: [\"getTenant\", \"listTenants\"],\n manage: [\"createOrUpdateTenant\"],\n};\n","import { User } from \"@knocklabs/node\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\nimport { serializeMessageResponse } from \"../utils.js\";\nfunction maybeHideUserData(user: User, hideUserData: boolean = false) {\n if (hideUserData) {\n return { id: user.id };\n }\n return user;\n}\n\nconst getUser = KnockTool({\n method: \"get_user\",\n name: \"Get user\",\n description: `\n Retrieves the complete user object for the given userId, including email, name, phone number, and any custom properties. Use this tool when you need to retrieve a user's complete profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to retrieve.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const user = await publicClient.users.get(params.userId ?? config.userId);\n\n return maybeHideUserData(user, config.hideUserData);\n },\n});\n\nconst createOrUpdateUser = KnockTool({\n method: \"upsert_user\",\n name: \"Create or update user\",\n description: `\n Creates a new user if they don't exist, or updates the user object for the given userId, including email, name, phone number, and any custom properties.\n \n Use this tool when you need to update a user's profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the user in. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to update.\"),\n email: z\n .string()\n .optional()\n .describe(\"(string): The email of the User to update.\"),\n name: z\n .string()\n .optional()\n .describe(\"(string): The name of the User to update.\"),\n phoneNumber: z\n .string()\n .optional()\n .describe(\"(string): The phone number of the User to update.\"),\n customProperties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): A dictionary of custom properties to update for the User.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const user = await publicClient.users.update(\n params.userId ?? config.userId,\n {\n email: params.email,\n name: params.name,\n phone_number: params.phoneNumber,\n ...(params.customProperties ?? {}),\n }\n );\n\n return maybeHideUserData(user, config.hideUserData);\n },\n});\n\nconst getUserPreferences = KnockTool({\n method: \"get_user_preferences\",\n name: \"Get user preferences\",\n description: `\n Retrieves the user's notification preferences for the given userId.\n\n If the userId is not provided, it will use the userId from the config. \n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user preferences from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\n \"(string): The userId of the User to retrieve Preferences for.\"\n ),\n preferenceSetId: z\n .string()\n .optional()\n .describe(\n \"(string): The preferenceSetId of the User to retrieve preferences for. Defaults to `default`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: params.preferenceSetId ?? \"default\",\n }\n );\n },\n});\n\nconst setUserPreferences = KnockTool({\n method: \"set_user_preferences\",\n name: \"Set user preferences\",\n description: `\n Overwrites the user's notification preferences for the given userId. Allows setting per-workflow, per-category, or per-channel notification preferences. Use this tool when you are asked to update a user's notification preferences.\n\n If the userId is not provided, it will use the userId from the config.\n\n Instructions:\n\n - You must ALWAYS provide a full preference set to this tool.\n - When setting per-workflow preferences, the key in the object should be the workflow key.\n - Workflow and category preferences should always have channel types underneath.\n - The channel types available to you are: email, sms, push, chat, and in_app_feed.\n - To turn OFF a preference, you must set it to false.\n - To turn ON a preference, you must set it to true.\n\n <examples>\n <example>\n <description>\n Update the user's preferences to turn off email notifications for the \"welcome\" workflow.\n </description>\n <input>\n {\n \"workflows\": {\n \"welcome\": {\n \"channel_types\": {\n \"email\": false\n }\n }\n }\n }\n </example>\n </examples>\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to set the user preferences in. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to update preferences for.\"),\n workflows: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The workflows to update where the key is the workflow key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n categories: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The categories to update where the key is the category key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n channel_types: z\n .record(z.string(), z.boolean())\n .optional()\n .describe(\n \"(object): The channel types to update where the key is the channel type, and the value of the object is a boolean value.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const existingPreferences = await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: \"default\",\n }\n );\n\n const updatedPreferences = {\n ...existingPreferences,\n workflows: {\n ...existingPreferences.workflows,\n ...params.workflows,\n },\n categories: {\n ...existingPreferences.categories,\n ...params.categories,\n },\n channel_types: {\n ...existingPreferences.channel_types,\n ...params.channel_types,\n },\n };\n\n return await publicClient.users.setPreferences(\n params.userId ?? config.userId,\n updatedPreferences\n );\n },\n});\n\nconst getUserMessages = KnockTool({\n method: \"get_user_messages\",\n name: \"Get user messages\",\n description: `\n Retrieves the messages that this user has received from the service. Use this tool when you need information about the notifications that the user has received, including if the message has been read, seen, or interacted with. This will return a list of messages across all of the channels.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user messages from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to retrieve messages for.\"),\n workflowRunId: z\n .string()\n .optional()\n .describe(\n \"(string): The workflowRunId of the User to retrieve. Use this when you want to retrieve messages sent from a workflow trigger.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const messages = await publicClient.users.getMessages(\n params.userId ?? config.userId,\n {\n workflow_run_id: params.workflowRunId,\n }\n );\n\n return messages.items.map(serializeMessageResponse);\n },\n});\n\nexport const users = {\n getUser,\n createOrUpdateUser,\n getUserPreferences,\n setUserPreferences,\n getUserMessages,\n};\n\nexport const permissions = {\n read: [\"getUser\", \"getUserMessages\", \"getUserPreferences\"],\n manage: [\"createOrUpdateUser\", \"setUserPreferences\"],\n};\n","import { Workflow } from \"@knocklabs/mgmt/resources/index.mjs\";\nimport jsonSchemaToZod from \"json-schema-to-zod\";\nimport { z } from \"zod\";\n\nimport { Config } from \"../../types.js\";\nimport { KnockClient } from \"../knock-client.js\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nimport { recipientSchema } from \"./shared.js\";\n\n/**\n * Converts a workflow into a tool that can be used to trigger the workflow.\n *\n * @param workflow - The workflow to convert to a tool.\n *\n * @returns A `KnockTool` that can be used to trigger the workflow.\n */\nfunction workflowAsTool(workflow: Workflow) {\n return KnockTool({\n method: `trigger_${workflow.key.replace(\"-\", \"_\")}_workflow`,\n name: `Trigger ${workflow.name} workflow`,\n description: `Triggers the ${workflow.name} workflow. Use this tool when you're asked to notify, send, or trigger for ${workflow.name} or ${workflow.key}.\n\n ${workflow.description ? `Additional information to consider on when to use this tool: ${workflow.description}` : \"\"}\n \n Returns the workflow run ID, which can be used to lookup messages produced by the workflow.`,\n parameters: z.object({\n environment: z.string().optional(),\n actor: recipientSchema\n .optional()\n .describe(\"An optional actor to trigger the workflow with.\"),\n recipients: z\n .array(recipientSchema)\n .describe(\n \"An optional array of recipients to trigger the workflow with.\"\n )\n .optional(),\n // Here we dynamically generate a zod schema from the workflow's `trigger_data_json_schema`\n // This allows us to validate the data passed to the workflow\n data: workflow.trigger_data_json_schema\n ? eval(jsonSchemaToZod(workflow.trigger_data_json_schema)).describe(\n \"The data to pass to the workflow.\"\n )\n : z\n .record(z.string(), z.any())\n .optional()\n .describe(\"The data to pass to the workflow.\"),\n tenant: z\n .string()\n .optional()\n .describe(\"The tenant ID to trigger the workflow for.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const result = await publicClient.workflows.trigger(workflow.key, {\n recipients: params.recipients ?? [config.userId],\n actor: params.actor,\n data: params.data,\n tenant: params.tenant ?? config.tenantId,\n });\n\n return result.workflow_run_id;\n },\n });\n}\n\n/**\n * Creates a tool for each workflow in the given environment.\n *\n * @param knockClient - The Knock client to use to list workflows.\n * @param config - The config to use to list workflows.\n *\n * @returns An array of `KnockTool`s that can be used to trigger the workflows.\n */\nasync function createWorkflowTools(\n knockClient: KnockClient,\n config: Config,\n workflowKeysToInclude?: string[]\n) {\n const workflows: Workflow[] = [];\n\n for await (const workflow of knockClient.workflows.list({\n environment: config.environment ?? \"development\",\n })) {\n // If we have a list of workflow keys to include, and the current workflow is not in the list, skip it\n if (\n workflowKeysToInclude &&\n !workflowKeysToInclude.includes(workflow.key)\n ) {\n continue;\n }\n\n workflows.push(workflow);\n }\n\n // Build a tool for each workflow\n return workflows.map((workflow) => workflowAsTool(workflow));\n}\n\nexport { createWorkflowTools, workflowAsTool };\n","import { toolPermissions, tools } from \"../lib/tools/index.js\";\nimport { ToolkitConfig, ToolCategory } from \"../types.js\";\n\nimport { KnockClient } from \"./knock-client.js\";\nimport { KnockTool } from \"./knock-tool.js\";\nimport { createWorkflowTools } from \"./tools/workflows-as-tools.js\";\n\n/**\n * Given a list of tools, and some config may describe the tools that should be provided to the LLM,\n * returns a filtered list of tools that match the config.\n *\n * Options:\n * `*` - All tools\n * `users.*` - All tools that start with `users.`\n * `users.getUser` - A specific tool\n *\n */\nexport function filterTools(\n tools: Record<string, Record<string, KnockTool>>,\n pattern: string | undefined\n): KnockTool[] {\n if (!pattern) {\n throw new Error(\"No pattern provided\");\n }\n\n // If the pattern is `*`, return all tools\n if (pattern === \"*\") {\n return Object.values(tools).flatMap((category) => Object.values(category));\n }\n\n const [category, tool] = pattern.split(\".\");\n\n // If the pattern is `*.*`, return all tools\n if (category === \"*\" && tool === \"*\") {\n return Object.values(tools).flatMap((category) => Object.values(category));\n }\n\n if (category && !tools[category]) {\n throw new Error(`Tool category ${category} not found`);\n }\n\n // If the pattern is `users.*`, return all tools that start with `users.`\n if (category && tool === \"*\") {\n return Object.values(tools[category]);\n }\n\n // If the pattern is `users.getUser`, return the `getUser` tool\n if (category && tool && !tools[category][tool]) {\n throw new Error(`Tool ${pattern} not found`);\n }\n\n return [tools[category][tool]];\n}\n\n/**\n * Given a category and a list of permissions, return a list of tools that the user has permission to use.\n *\n * @param category - The category to get tools for\n * @param categoryPermissions - The permissions to use\n * @returns A list of tools that the user has permission to use\n */\nexport function getToolsWithPermissions(\n category: keyof typeof toolPermissions,\n categoryPermissions: Record<string, boolean | string[] | undefined>\n) {\n // Return all of the tools for the category that have permission\n const toolsInCategory = tools[category] as Record<string, KnockTool>;\n const toolPermissionsInCategory = toolPermissions[category] as Record<\n string,\n string[]\n >;\n\n // Look over each permission type, like `read: true`\n // If it's `true`, then find all of the tools that have that permission\n return Object.entries(categoryPermissions).reduce(\n (acc: KnockTool[], [permissionType, hasPermission]) => {\n if (\n (Array.isArray(hasPermission) && hasPermission.length > 0) ||\n hasPermission === true\n ) {\n return acc.concat(\n toolPermissionsInCategory[permissionType].map(\n (toolName) => toolsInCategory[toolName]\n )\n );\n }\n return acc;\n },\n []\n );\n}\n\n/**\n * Given a config, return a list of tools for each category that the user has permission to use.\n *\n * If the user has run permissions for workflows, then we need to get the workflow triggers tools,\n * and add them to the list of tools for the workflows category.\n *\n * @param config - The config to use\n * @returns A list of tools for each category that the user has permission to use\n */\nexport async function getToolsByPermissionsInCategories(\n knockClient: KnockClient,\n config: ToolkitConfig\n): Promise<Record<ToolCategory, KnockTool[]>> {\n const toolsByCategory = Object.keys(config.permissions).reduce(\n (acc, category) => {\n const categoryKey = category as ToolCategory;\n const categoryPermissions = config.permissions[categoryKey];\n\n if (tools[categoryKey] && categoryPermissions) {\n const tools = getToolsWithPermissions(categoryKey, categoryPermissions);\n\n return { ...acc, [categoryKey]: tools };\n }\n\n return acc;\n },\n {} as Record<ToolCategory, KnockTool[]>\n );\n\n // If the user has run permissions for workflows, then we need to get the workflow triggers tools,\n // and add them to the list of tools for the workflows category.\n if (\n config.permissions.workflows &&\n config.permissions.workflows.trigger &&\n Array.isArray(config.permissions.workflows.trigger)\n ) {\n const workflowTools = await createWorkflowTools(\n knockClient,\n config,\n config.permissions.workflows.trigger\n );\n toolsByCategory.workflows = [\n ...toolsByCategory.workflows,\n ...workflowTools,\n ];\n }\n\n return toolsByCategory;\n}\n\n/**\n * Given a list of tools, return a map of tools by method name.\n *\n * @param tools - The tools to serialize\n * @returns A map of tools by method name\n */\nexport function getToolMap(tools: KnockTool[]) {\n return tools.reduce(\n (acc, tool) => {\n acc[tool.method] = tool;\n return acc;\n },\n {} as Record<string, KnockTool>\n );\n}\n\n/**\n * Serialize a message response from the API to a more LLM-friendly format.\n *\n * @param message - The message to serialize\n * @returns A serialized message\n */\nexport function serializeMessageResponse(message: Record<string, any>) {\n return {\n id: message.id,\n status: message.status,\n engagement_statuses: message.engagement_statuses,\n data: message.data,\n metadata: message.metadata,\n };\n}\n","import { Workflow, WorkflowStep } from \"@knocklabs/mgmt/resources/index.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nimport { workflowStepTools } from \"./workflow-steps.js\";\n\n/**\n * A slimmed down version of the Workflow resource that is easier to work with in the LLM.\n */\nexport type SerializedWorkflow = {\n key: string;\n name: string;\n description: string | undefined;\n categories: string[] | undefined;\n schema: Record<string, unknown> | undefined;\n};\n\nexport function serializeWorkflowResponse(\n workflow: Workflow\n): SerializedWorkflow {\n return {\n key: workflow.key,\n name: workflow.name,\n description: workflow.description,\n categories: workflow.categories,\n schema: workflow.trigger_data_json_schema,\n };\n}\n\nexport function serializeFullWorkflowResponse(\n workflow: Workflow\n): SerializedWorkflow & { steps: WorkflowStep[] } {\n return {\n key: workflow.key,\n name: workflow.name,\n description: workflow.description,\n categories: workflow.categories,\n schema: workflow.trigger_data_json_schema,\n steps: workflow.steps,\n };\n}\n\nconst listWorkflows = KnockTool({\n method: \"list_workflows\",\n name: \"List workflows\",\n description: `\n List all workflows available for the given environment. Returns structural information about the workflows, including the key, name, description, and categories.\n\n Use this tool when you need to understand which workflows are available to be called.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list workflows for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allWorkflows: SerializedWorkflow[] = [];\n const listParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n };\n\n for await (const workflow of knockClient.workflows.list(listParams)) {\n allWorkflows.push(serializeWorkflowResponse(workflow));\n }\n\n return allWorkflows;\n },\n});\n\nconst getWorkflow = KnockTool({\n method: \"get_workflow\",\n name: \"Get workflow\",\n description: `\n Get a workflow by key. Returns structural information about the workflow, including the key, name, description, and categories.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the workflow for. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: params.environment ?? config.environment ?? \"development\",\n });\n\n return serializeFullWorkflowResponse(workflow);\n },\n});\n\nconst triggerWorkflow = KnockTool({\n method: \"trigger_workflow\",\n name: \"Trigger workflow\",\n description: `\n Trigger a workflow for one or more recipients, which may produce one or more messages for each recipient depending on the workflow's steps.\n\n Use this tool when you need to trigger a workflow to send a notification across the channels configured for the workflow. \n\n When recipients aren't provided, the workflow will be triggered for the current user specified in the config.\n\n Returns the workflow run ID, which can be used to lookup messages produced by the workflow.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to trigger the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to trigger.\"),\n recipients: z\n .array(z.string())\n .optional()\n .describe(\n \"(array): The recipients to trigger the workflow for. This is an array of user IDs.\"\n ),\n data: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): Data to pass to the workflow.\"),\n tenant: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The tenant to trigger the workflow for. Must contain an id if being sent.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const result = await publicClient.workflows.trigger(params.workflowKey, {\n recipients: params.recipients ?? [config.userId] ?? [],\n data: params.data,\n tenant: params.tenant ?? config.tenantId,\n });\n\n return result.workflow_run_id;\n },\n});\n\nconst createWorkflow = KnockTool({\n method: \"create_workflow\",\n name: \"Create workflow\",\n description: `\n Create a new workflow, which is used to control the flow of notifications. Use this tool when you're asked to create a new workflow, or you need to create a new workflow before adding a step to it.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\n \"(string): The key of the workflow to create. Only use a kebab-case string with no spaces or special characters.\"\n ),\n name: z.string().describe(\"(string): The name of the workflow.\"),\n description: z\n .string()\n .describe(\"(string): The description of the workflow.\"),\n categories: z\n .array(z.string())\n .describe(\"(array): The categories to add to the workflow.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const result = await knockClient.workflows.upsert(params.workflowKey, {\n environment: config.environment ?? \"development\",\n workflow: {\n name: params.name,\n description: params.description,\n categories: params.categories ?? [],\n steps: [],\n },\n });\n\n return serializeWorkflowResponse(result.workflow);\n },\n});\n\nconst createOneOffWorkflowSchedule = KnockTool({\n method: \"create_one_off_workflow_schedule\",\n name: \"Create one-off workflow schedule\",\n description: `\n Create a one-off workflow schedule for a user. Use this tool when you need to schedule the execution of a workflow for a specific user in the future, like to power a delayed notification.\n \n Schedules can accept a set of data that will be passed to the workflow trigger when it is executed. When the userId is not provided, the schedule will be created for the current user specified in the config.\n\n Examples:\n \n - In three days, send a welcome email to a user\n - In one hour, send a password reset email to a user\n - In two weeks, send a survey to a user\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to schedule.\"),\n userId: z\n .string()\n .describe(\n \"(string): The userId of the user to schedule the workflow for.\"\n ),\n scheduledAt: z\n .string()\n .describe(\n \"(string): The date and time to schedule the workflow for. Must be in ISO 8601 format.\"\n ),\n data: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): Data to pass to the workflow.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.workflows.createSchedules(params.workflowKey, {\n recipients: [params.userId ?? config.userId],\n scheduled_at: params.scheduledAt,\n data: params.data,\n });\n },\n});\n\nexport const workflows = {\n listWorkflows,\n getWorkflow,\n triggerWorkflow,\n createWorkflow,\n ...workflowStepTools,\n createOneOffWorkflowSchedule,\n};\n\nexport const permissions = {\n read: [\"listWorkflows\", \"getWorkflow\"],\n manage: [\n \"createWorkflow\",\n \"createOneOffWorkflowSchedule\",\n \"triggerWorkflow\",\n ].concat(...Object.keys(workflowStepTools)),\n trigger: [],\n};\n","import {\n ChatTemplate,\n EmailTemplate,\n InAppFeedTemplate,\n PushTemplate,\n SMSTemplate,\n Workflow,\n WorkflowStep,\n WorkflowUpsertParams,\n} from \"@knocklabs/mgmt/resources/index.js\";\nimport { z } from \"zod\";\n\nimport { KnockClient } from \"../knock-client.js\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nimport { serializeWorkflowResponse } from \"./workflows\";\n\nfunction generateStepRef(stepType: string) {\n const randomString = Math.random().toString(36).substring(2, 7).toUpperCase();\n return `${stepType}_${randomString}`;\n}\n\nasync function updateWorkflowWithStep(\n knockClient: KnockClient,\n workflow: Workflow,\n step: WorkflowStep,\n environment: string\n) {\n let workflowSteps = workflow.steps;\n const existingStepIdx = workflow.steps.findIndex((s) => s.ref === step.ref);\n\n // If the step already exists, update it. Otherwise, add it to the end of the steps array.\n if (existingStepIdx !== -1) {\n workflowSteps[existingStepIdx] = step;\n } else {\n workflowSteps.push(step);\n }\n\n const workflowParams: WorkflowUpsertParams = {\n environment,\n workflow: {\n ...workflow,\n steps: workflowSteps,\n },\n };\n\n const result = await knockClient.workflows.upsert(\n workflow.key,\n workflowParams\n );\n\n return serializeWorkflowResponse(result.workflow);\n}\n\nconst SHARED_PROMPTS = {\n workflow: `\n To use this tool, you MUST first create a workflow using the \\`createWorkflow\\` tool, or get an existing workflow using the \\`getWorkflow\\` tool. \n \n If you are updating an existing step, you can pass the \\`stepRef\\` parameter to the tool. If you do not pass the \\`stepRef\\` parameter, a new step will be created and added to the end of the workflow's steps array. You should ONLY pass the \\`stepRef\\` parameter if you are updating an existing step.\n `,\n liquid: `\n ## Personalization\n\n If you need to include personalization, you can use liquid to include dynamic content in the email and the subject line.\n The following variables are always available to use in liquid:\n\n - \\`recipient.id\\`: The ID of the recipient.\n - \\`recipient.name\\`: The name of the recipient.\n - \\`recipient.email\\`: The email of the recipient.\n - \\`recipient.phone_number\\`: The phone number of the recipient.\n\n You can supply **any** other dynamic variables you think are needed by referencing them under the \\`data\\` key. You add those like \\`{{ data.variable_name }}\\`.\n\n <example>\n # Hello, {{ recipient.name }}\n\n This is a dynamic message:\n\n > {{ data.message }}\n </example>\n\n ## Liquid helpers\n\n You have access to a full suite of liquid helpers to help you perform common templating tasks. The full list of helper is available here: https://docs.knock.app/designing-workflows/template-editor/reference-liquid-helpers.\n\n <example>\n Hello, {{ recipient.name | split: \" \" | first | default: \"there\" }}\n </example>\n `,\n};\n\nconst contentBlockSchema = z.union([\n z.object({\n type: z.literal(\"markdown\"),\n content: z\n .string()\n .describe(\"(string): The markdown content of the block.\"),\n }),\n z.object({\n type: z.literal(\"html\"),\n content: z.string().describe(\"(string): The HTML content of the block.\"),\n }),\n z.object({\n type: z.literal(\"image\"),\n url: z.string().describe(\"(string): The URL of the image.\"),\n }),\n z.object({\n type: z.literal(\"button_set\"),\n buttons: z\n .array(\n z.object({\n label: z.string().describe(\"(string): The label of the button.\"),\n action: z.string().describe(\"(string): The action of the button.\"),\n variant: z\n .enum([\"solid\", \"outline\"])\n .default(\"solid\")\n .describe(\n \"(enum): The variant of the button. Defaults to `solid`.\"\n ),\n })\n )\n .describe(\"(array): The buttons for the button set.\"),\n }),\n z.object({\n type: z.literal(\"divider\"),\n }),\n z.object({\n type: z.literal(\"partial\"),\n key: z.string().describe(\"(string): The key of the partial to use.\"),\n name: z.string().describe(\"(string): The name of the partial.\"),\n attrs: z\n .record(z.string(), z.string())\n .describe(\n \"(object): The attributes for the partial. ALWAYS supply an empty object when you don't know which params are required.\"\n ),\n }),\n]);\n\nconst createOrUpdateEmailStepInWorkflow = KnockTool({\n method: \"upsert_workflow_email_step\",\n name: \"Create or update email step in workflow\",\n description: `\n Creates or updates an email step in a workflow. Use this tool when you're asked to create an email notification and you need to specify the content of the email.\n\n ${SHARED_PROMPTS.workflow}\n\n When you're asked to create an email step, you can either set the HTML content directly or use blocks to build the email. If you're asked to set the HTML content directly, you can use the \\`htmlContent\\` parameter. We prefer to use blocks.\n\n ## Blocks\n\n The content of the email is supplied as an array of \"blocks\". The simplest block is a \"markdown\" block, which supports content in a markdown format. That should always be your default block type.\n\n The following block types are supported:\n\n - \\`markdown\\`: A block that supports markdown content.\n - \\`html\\`: A block that supports markdown content.\n - \\`image\\`: A block that supports an image.\n - \\`button_set\\`: A block that adds one or more buttons.\n - \\`divider\\`: A block that supports a divider.\n - \\`partial\\`: A block that supports rendering a shared content partial.\n\n <example>\n {\n \"blocks\": [\n {\n \"type\": \"markdown\",\n \"content\": \"# Greetings from Knock!\\nHello, {{ recipient.name }}.\"\n },\n {\n \"type\": \"divider\"\n },\n {\n \"type\": \"button_set\",\n \"buttons\": [\n {\n \"label\": \"Approve\",\n \"action\": \"{{ data.primary_action_url }}\",\n \"variant\": \"solid\"\n }\n ]\n }\n ]\n }\n </example>\n\n ### Markdown\n\n When using the \\`markdown\\` block, you must supply a \\`content\\` key. The \\`content\\` key supports markdown.\n\n <example>\n {\n \"type\": \"markdown\",\n \"content\": \"Hello, world!\"\n }\n </example>\n\n ### HTML\n\n The \\`html\\` block supports raw HTML content. This should be used sparingly, and only when you need to include custom HTML content that markdown doesn't support. When using the \\`html\\` block, you must supply a \\`content\\` key. HTML content can include liquid personalization.\n\n ### Button sets\n\n Button sets are a special type of block that allows you to add one or more buttons to the email. They're useful for directing users to take specific actions. Button sets support one or more buttons. You must always include at least one button in a button set.\n\n Buttons are specified in a button set under the \\`buttons\\` key. Each button requires a \\`label\\`, \\`action\\`, and \\`variant\\`. The ONLY valid variants are \\`solid\\` and \\`outline\\`. The label and action can allowed be dynamic variables using liquid.\n\n <example>\n {\n \"type\": \"button_set\",\n \"buttons\": [\n {\n \"label\": \"Approve\",\n \"action\": \"https://example.com\",\n \"variant\": \"solid\"\n }\n ]\n }\n </example>\n\n ### Image\n\n Images are a special type of block that allows you to add an image to the email. When using the \\`image\\` block, you must supply a \\`url\\` key. The \\`url\\` key supports a URL to an image.\n\n <example>\n {\n \"type\": \"image\",\n \"url\": \"https://example.com/image.png\"\n }\n </example>\n\n ${SHARED_PROMPTS.liquid}\n\n ## Partials\n\n If you need to reuse content across multiple emails, you can create or reference an existing partial and reference it in the email. You should only use partials if you're instructed to do so.\n\n When you do need to use a partial in an email, you can use the \\`partial\\` block and then set the \\`key\\` to the key of the partial you want to use. If the partial requires any variables, you pass those in the \\`attrs\\` key.\n\n ## Writing style\n\n Unless asked otherwise, you should write content for the email in a concise and formal writing style. Do NOT use complex language or try to over explain. Keep the subject line to 8 words or less.\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n htmlContent: z\n .string()\n .optional()\n .describe(\n \"(string): The HTML content of the email template. Use this when not setting blocks.\"\n ),\n blocks: z\n .array(contentBlockSchema)\n .optional()\n .describe(\n \"(array): The blocks for the email step. Use this when you don't need to set HTML directly.\"\n ),\n layoutKey: z\n .string()\n .describe(\"(string): The key of the layout to use for the email step.\"),\n subject: z.string().describe(\"(string): The subject of the email step.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const emailChannelsPage = await knockClient.channels.list();\n const emailChannels = emailChannelsPage.entries.filter(\n (channel) => channel.type === \"email\"\n );\n\n if (emailChannels.length === 0) {\n throw new Error(\"No email channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: emailChannels[0].key,\n template: {\n settings: {\n layout_key: params.layoutKey ?? \"default\",\n },\n subject: params.subject,\n visual_blocks: params.blocks,\n html_content: params.htmlContent,\n } as EmailTemplate,\n ref: params.stepRef ?? generateStepRef(\"email\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst createOrUpdateSmsStepInWorkflow = KnockTool({\n method: \"upsert_workflow_sms_step\",\n name: \"Create or update sms step in workflow\",\n description: `\n Creates an SMS step in a workflow. Use this tool when you're asked to create an SMS notification and you need to specify the content of the SMS.\n\n ${SHARED_PROMPTS.workflow}\n\n ${SHARED_PROMPTS.liquid}\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n content: z.string().describe(\"(string): The content of the SMS.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const smsChannelsPage = await knockClient.channels.list();\n const smsChannels = smsChannelsPage.entries.filter(\n (channel) => channel.type === \"sms\"\n );\n\n if (smsChannels.length === 0) {\n throw new Error(\"No SMS channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: smsChannels[0].key,\n template: {\n text_body: params.content,\n } as SMSTemplate,\n ref: params.stepRef ?? generateStepRef(\"sms\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst createOrUpdatePushStepInWorkflow = KnockTool({\n method: \"upsert_workflow_push_step\",\n name: \"Create or update push step in workflow\",\n description: `\n Creates a push step in a workflow. Use this tool when you're asked to create a push notification and you need to specify the content of the push notification.\n\n ${SHARED_PROMPTS.workflow}\n\n ${SHARED_PROMPTS.liquid}\n\n Be terse in your writing as this is a push notification and should be direct and to the point.\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n title: z.string().describe(\"(string): The title of the push notification.\"),\n content: z\n .string()\n .describe(\"(string): The content (body) of the push notification.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const pushChannelsPage = await knockClient.channels.list();\n const pushChannels = pushChannelsPage.entries.filter(\n (channel) => channel.type === \"push\"\n );\n\n if (pushChannels.length === 0) {\n throw new Error(\"No push channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: pushChannels[0].key,\n template: {\n title: params.title,\n text_body: params.content,\n } as PushTemplate,\n ref: params.stepRef ?? generateStepRef(\"push\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\n// TODO: Add support for action buttons, not just the action URL\nconst createOrUpdateInAppFeedStepInWorkflow = KnockTool({\n method: \"upsert_workflow_in_app_step\",\n name: \"Create or update in app feed step in workflow\",\n description: `\n Creates an in app feed step in a workflow. Use this tool when you're asked to create an in app feed notification and you need to specify the content of the in app feed notification.\n\n ${SHARED_PROMPTS.workflow}\n\n ${SHARED_PROMPTS.liquid}\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n actionUrl: z\n .string()\n .describe(\n \"(string): The URL to navigate to when the in app feed is tapped.\"\n ),\n body: z\n .string()\n .describe(\"(string): The markdown content of the in app feed.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const inAppChannelsPage = await knockClient.channels.list();\n const inAppChannels = inAppChannelsPage.entries.filter(\n (channel) => channel.type === \"in_app_feed\"\n );\n\n if (inAppChannels.length === 0) {\n throw new Error(\"No in app channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: inAppChannels[0].key,\n template: {\n action_url: params.actionUrl,\n markdown_body: params.body,\n } as InAppFeedTemplate,\n ref: params.stepRef ?? generateStepRef(\"in_app_feed\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst createOrUpdateChatStepInWorkflow = KnockTool({\n method: \"upsert_workflow_chat_step\",\n name: \"Create or update chat step in workflow\",\n description: `\n Creates a chat step in a workflow. Use this tool when you're asked to create a chat, Slack, Discord, or Microsoft Teams notification and you need to specify the content of the chat notification.\n\n ${SHARED_PROMPTS.workflow}\n\n ${SHARED_PROMPTS.liquid}\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n body: z\n .string()\n .describe(\"(string): The markdown content of the notification.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const chatChannelsPage = await knockClient.channels.list();\n const chatChannels = chatChannelsPage.entries.filter(\n (channel) => channel.type === \"chat\"\n );\n\n if (chatChannels.length === 0) {\n throw new Error(\"No chat channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: chatChannels[0].key,\n template: {\n markdown_body: params.body,\n } as ChatTemplate,\n ref: params.stepRef ?? generateStepRef(\"chat\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst createOrUpdateDelayStepInWorkflow = KnockTool({\n method: \"upsert_workflow_delay_step\",\n name: \"Create or update delay step in workflow\",\n description: `\n Creates a delay step in a workflow. Use this tool when you're asked to add a delay to the workflow that pauses, or waits for a period of time before continuing.\n\n ${SHARED_PROMPTS.workflow}\n\n Delays are specified in \"unit\" and \"value\" pairs. The only valid units are \"seconds\", \"minutes\", \"hours\", and \"days\".\n\n <example>\n {\n \"delayValue\": 5,\n \"delayUnit\": \"minutes\"\n }\n </example>\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n delayValue: z.number().describe(\"(number): The value of the delay.\"),\n delayUnit: z\n .enum([\"seconds\", \"minutes\", \"hours\", \"days\"])\n .describe(\"(enum): The unit of the delay.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const workflowParams: WorkflowUpsertParams = {\n environment: config.environment ?? \"development\",\n workflow: {\n ...workflow,\n steps: [\n // @ts-expect-error\n ...workflow.steps,\n // @ts-expect-error\n {\n type: \"delay\",\n settings: {\n delay_for: {\n value: params.delayValue,\n unit: params.delayUnit,\n },\n },\n ref: params.stepRef ?? generateStepRef(\"delay\"),\n },\n ],\n },\n };\n\n const result = await knockClient.workflows.upsert(\n params.workflowKey,\n workflowParams\n );\n\n return serializeWorkflowResponse(result.workflow);\n },\n});\n\nconst createOrUpdateBatchStepInWorkflow = KnockTool({\n method: \"upsert_workflow_batch_step\",\n name: \"Create or update batch step in workflow\",\n description: `\n Creates a batch step in a workflow. Use this tool when you're asked to create a batch step or asked to add digesting behavior to a workflow. The batch step collects multiple workflow triggers for a single recipient over a period of time and then flushes the content to the next step.\n\n ${SHARED_PROMPTS.workflow}\n\n Batch windows are specified in \"unit\" and \"value\" pairs. The only valid units are \"seconds\", \"minutes\", \"hours\", and \"days\".\n\n <example>\n {\n \"batchWindow\": {\n \"value\": 5,\n \"unit\": \"minutes\"\n }\n }\n </example>\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n batchWindow: z.object({\n value: z.number().describe(\"(number): The value of the batch window.\"),\n unit: z\n .enum([\"seconds\", \"minutes\", \"hours\", \"days\"])\n .describe(\"(enum): The unit of the batch window.\"),\n }),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"batch\",\n settings: {\n batch_window: {\n value: params.batchWindow.value,\n unit: params.batchWindow.unit,\n },\n },\n ref: params.stepRef ?? generateStepRef(\"batch\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst workflowStepTools = {\n // Channel steps\n createOrUpdateEmailStepInWorkflow,\n createOrUpdateSmsStepInWorkflow,\n createOrUpdatePushStepInWorkflow,\n createOrUpdateInAppFeedStepInWorkflow,\n createOrUpdateChatStepInWorkflow,\n\n // Function steps\n createOrUpdateDelayStepInWorkflow,\n createOrUpdateBatchStepInWorkflow,\n};\n\nexport { workflowStepTools };\n","import { channels, permissions as channelsPermissions } from \"./channels.js\";\nimport { commits, permissions as commitsPermissions } from \"./commits.js\";\nimport {\n documentation,\n permissions as documentationPermissions,\n} from \"./documentation.js\";\nimport {\n emailLayouts,\n permissions as emailLayoutsPermissions,\n} from \"./email-layouts.js\";\nimport {\n environments,\n permissions as environmentsPermissions,\n} from \"./environments.js\";\nimport { guides, permissions as guidesPermissions } from \"./guides.js\";\nimport {\n messageTypes,\n permissions as messageTypesPermissions,\n} from \"./message-types.js\";\nimport { messages, permissions as messagesPermissions } from \"./messages.js\";\nimport { objects, permissions as objectsPermissions } from \"./objects.js\";\nimport { partials, permissions as partialsPermissions } from \"./partials.js\";\nimport { tenants, permissions as tenantsPermissions } from \"./tenants.js\";\nimport { users, permissions as usersPermissions } from \"./users.js\";\nimport { workflows, permissions as workflowsPermissions } from \"./workflows.js\";\n\nexport const tools = {\n channels,\n commits,\n documentation,\n emailLayouts,\n environments,\n guides,\n messages,\n messageTypes,\n objects,\n partials,\n tenants,\n users,\n workflows,\n};\n\nexport const allTools = {\n ...channels,\n ...commits,\n ...documentation,\n ...emailLayouts,\n ...environments,\n ...guides,\n ...messageTypes,\n ...messages,\n ...objects,\n ...partials,\n ...tenants,\n ...users,\n ...workflows,\n};\n\nexport const toolPermissions = {\n channels: channelsPermissions,\n commits: commitsPermissions,\n documentation: documentationPermissions,\n emailLayouts: emailLayoutsPermissions,\n environments: environmentsPermissions,\n guides: guidesPermissions,\n messages: messagesPermissions,\n messageTypes: messageTypesPermissions,\n objects: objectsPermissions,\n partials: partialsPermissions,\n tenants: tenantsPermissions,\n users: usersPermissions,\n workflows: workflowsPermissions,\n};\n"],"mappings":";AACA,SAAS,SAAS;AAgDlB,IAAM,YAAY,CAAC,SACjB,KACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,KAAK,IAAI;AAE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AAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,WAAW;AAAA,EACtB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEO,IAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,EACV,SAASC;AAAA,EACT,eAAeA;AAAA,EACf,cAAcA;AAAA,EACd,cAAcA;AAAA,EACd,QAAQA;AAAA,EACR,UAAUA;AAAA,EACV,cAAcA;AAAA,EACd,SAASA;AAAA,EACT,UAAUA;AAAA,EACV,SAASA;AAAA,EACT,OAAOA;AAAA,EACP,WAAWA;AACb;","names":["z","z","permissions","z","z","permissions","z","z","permissions","permissions","z","z","z","permissions","z","z","permissions","z","z","permissions","z","z","permissions","z","z","permissions","z","z","permissions","z","z","z","workflows","workflow","tools","category","z","messages","permissions","z","z","workflow","z","workflow","z","permissions","permissions"]}
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  allTools,
3
3
  createWorkflowTools
4
- } from "./chunk-WSJ5XINN.js";
4
+ } from "./chunk-3Q6IG57F.js";
5
5
 
6
6
  // src/modelcontextprotocol/adapter.ts
7
7
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8
8
  import { z } from "zod";
9
9
  var KnockMcpServer = class extends McpServer {
10
10
  constructor(knockClient, config, tools) {
11
- super({ name: "Knock", version: "0.4.0" });
11
+ super({ name: "Knock", version: "0.5.1" });
12
12
  tools.forEach((tool) => {
13
13
  const toolParams = tool.parameters ?? z.object({});
14
14
  this.tool(
@@ -44,4 +44,4 @@ var createKnockMcpServer = async (params) => {
44
44
  export {
45
45
  createKnockMcpServer
46
46
  };
47
- //# sourceMappingURL=chunk-LWVB2RKE.js.map
47
+ //# sourceMappingURL=chunk-OA5U6LZU.js.map
@@ -5,7 +5,7 @@ import { Knock } from "@knocklabs/node";
5
5
  // package.json
6
6
  var package_default = {
7
7
  name: "@knocklabs/agent-toolkit",
8
- version: "0.4.0",
8
+ version: "0.5.1",
9
9
  description: "A toolkit for working with Knock in Agent workflows.",
10
10
  main: "src/index.js",
11
11
  scripts: {
@@ -64,6 +64,7 @@ var package_default = {
64
64
  "@knocklabs/mgmt": "^0.2.0",
65
65
  "@knocklabs/node": "^1.10.3",
66
66
  "@modelcontextprotocol/sdk": "^1.7.0",
67
+ "@sentry/node": "^10.5.0",
67
68
  "json-schema-to-zod": "^2.6.1",
68
69
  uuid: "^11.1.0",
69
70
  yargs: "^17.7.2",
@@ -94,9 +95,9 @@ var package_default = {
94
95
  vitest: "^1.3.1"
95
96
  },
96
97
  peerDependencies: {
98
+ "@mastra/core": "^0.10.3",
97
99
  ai: "^4.0.0",
98
- openai: "^4.0.0",
99
- "@mastra/core": "^0.10.3"
100
+ openai: "^4.0.0"
100
101
  },
101
102
  peerDependenciesMeta: {
102
103
  ai: {
@@ -150,4 +151,4 @@ var createKnockClient = (config) => {
150
151
  export {
151
152
  createKnockClient
152
153
  };
153
- //# sourceMappingURL=chunk-PLL3H2Y6.js.map
154
+ //# sourceMappingURL=chunk-UBRPLPCX.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/knock-client.ts","../package.json"],"sourcesContent":["import KnockMgmt from \"@knocklabs/mgmt\";\nimport { Knock } from \"@knocklabs/node\";\n\nimport pkg from \"../../package.json\";\nimport { Config } from \"../types.js\";\n\nconst serviceTokensToApiClients: Record<string, Record<string, Knock>> = {};\n\ntype KnockClient = ReturnType<typeof createKnockClient>;\n\n// Include a custom header to identify all client requests in the API logs\nconst knockClientHeaders = {\n \"X-Knock-Client\": `knock/agent-toolkit@${pkg.version}`,\n};\n\nconst createKnockClient = (config: Config) => {\n const serviceToken = config.serviceToken ?? process.env.KNOCK_SERVICE_TOKEN;\n\n if (!serviceToken) {\n throw new Error(\n \"Service token is required. Please set the `serviceToken` property in the config or the `KNOCK_SERVICE_TOKEN` environment variable.\"\n );\n }\n\n const client = new KnockMgmt({\n serviceToken,\n defaultHeaders: knockClientHeaders,\n });\n\n return Object.assign(client, {\n publicApi: async (environmentSlug?: string): Promise<Knock> => {\n const environment =\n environmentSlug ?? config.environment ?? \"development\";\n\n // If the client already exists for this service token and environment, return it\n if (serviceTokensToApiClients?.[serviceToken]?.[environment]) {\n return serviceTokensToApiClients[serviceToken][environment];\n }\n\n // Otherwise, fetch a public API key for this service token and environment\n const { api_key } = await client.apiKeys.exchange({ environment });\n\n // Create a new Knock client with the public API key\n const knock = new Knock({\n apiKey: api_key,\n defaultHeaders: knockClientHeaders,\n });\n\n // Store the client in the cache\n if (!serviceTokensToApiClients[serviceToken]) {\n serviceTokensToApiClients[serviceToken] = {};\n }\n\n serviceTokensToApiClients[serviceToken][environment] = knock;\n\n return knock;\n },\n });\n};\n\nexport { createKnockClient, type KnockClient };\n","{\n \"name\": \"@knocklabs/agent-toolkit\",\n \"version\": \"0.4.0\",\n \"description\": \"A toolkit for working with Knock in Agent workflows.\",\n \"main\": \"src/index.js\",\n \"scripts\": {\n \"build\": \"tsup --env.NODE_ENV production\",\n \"clean\": \"rimraf ./dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint src --ext .ts,.tsx\",\n \"lint:fix\": \"eslint src --ext .ts,.tsx --fix\",\n \"format\": \"prettier --write \\\"src/**/*.{ts,tsx}\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.{ts,tsx}\\\"\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"release\": \"npm run build && npm run release:publish && changeset tag\",\n \"release:publish\": \"npm publish --access public --tolerate-republish\"\n },\n \"author\": \"Knock\",\n \"license\": \"MIT\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \"./openai\": {\n \"types\": \"./dist/openai/index.d.ts\",\n \"default\": \"./dist/openai/index.js\"\n },\n \"./ai-sdk\": {\n \"types\": \"./dist/ai-sdk/index.d.ts\",\n \"default\": \"./dist/ai-sdk/index.js\"\n },\n \"./langchain\": {\n \"types\": \"./dist/langchain/index.d.ts\",\n \"default\": \"./dist/langchain/index.js\"\n },\n \"./mastra\": {\n \"types\": \"./dist/mastra/index.d.ts\",\n \"default\": \"./dist/mastra/index.js\"\n },\n \"./modelcontextprotocol\": {\n \"types\": \"./dist/modelcontextprotocol/index.d.ts\",\n \"default\": \"./dist/modelcontextprotocol/index.js\"\n },\n \"./human-in-the-loop\": {\n \"types\": \"./dist/human-in-the-loop/index.d.ts\",\n \"default\": \"./dist/human-in-the-loop/index.js\"\n },\n \"./types\": {\n \"types\": \"./dist/types.d.ts\"\n }\n },\n \"bin\": {\n \"local-mcp\": \"dist/modelcontextprotocol/local-server.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"dependencies\": {\n \"@knocklabs/mgmt\": \"^0.2.0\",\n \"@knocklabs/node\": \"^1.10.3\",\n \"@modelcontextprotocol/sdk\": \"^1.7.0\",\n \"json-schema-to-zod\": \"^2.6.1\",\n \"uuid\": \"^11.1.0\",\n \"yargs\": \"^17.7.2\",\n \"zod\": \"^3.24.2\",\n \"zod-to-json-schema\": \"^3.24.5\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.28.1\",\n \"@eslint/js\": \"^9.24.0\",\n \"@langchain/core\": \"^0.3.45\",\n \"@types/node\": \"^22.13.10\",\n \"@types/yargs\": \"^17.0.33\",\n \"@typescript-eslint/eslint-plugin\": \"^8.29.1\",\n \"@typescript-eslint/parser\": \"^8.29.1\",\n \"ai\": \"^4.2.8\",\n \"eslint\": \"^9.24.0\",\n \"eslint-config-prettier\": \"^10.1.2\",\n \"eslint-import-resolver-typescript\": \"^4.3.2\",\n \"eslint-plugin-import\": \"^2.31.0\",\n \"eslint-plugin-prettier\": \"^5.2.6\",\n \"openai\": \"^4.90.0\",\n \"prettier\": \"^3.5.3\",\n \"rimraf\": \"^6.0.1\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.8.2\",\n \"typescript-eslint\": \"^8.29.1\",\n \"vitest\": \"^1.3.1\"\n },\n \"peerDependencies\": {\n \"ai\": \"^4.0.0\",\n \"openai\": \"^4.0.0\",\n \"@mastra/core\": \"^0.10.3\"\n },\n \"peerDependenciesMeta\": {\n \"ai\": {\n \"optional\": true\n }\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"],"mappings":";AAAA,OAAO,eAAe;AACtB,SAAS,aAAa;;;ACDtB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,SAAW;AAAA,IACT,OAAS;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,MAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,SAAW;AAAA,IACX,mBAAmB;AAAA,EACrB;AAAA,EACA,QAAU;AAAA,EACV,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,SAAW;AAAA,IACT,YAAY;AAAA,MACV,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,eAAe;AAAA,MACb,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,0BAA0B;AAAA,MACxB,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,uBAAuB;AAAA,MACrB,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,W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AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,IAAI,UAAU;AAAA,IAC3B;AAAA,IACA,gBAAgB;AAAA,EAClB,CAAC;AAED,SAAO,OAAO,OAAO,QAAQ;AAAA,IAC3B,WAAW,OAAO,oBAA6C;AAC7D,YAAM,cACJ,mBAAmB,OAAO,eAAe;AAG3C,UAAI,4BAA4B,YAAY,IAAI,WAAW,GAAG;AAC5D,eAAO,0BAA0B,YAAY,EAAE,WAAW;AAAA,MAC5D;AAGA,YAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,QAAQ,SAAS,EAAE,YAAY,CAAC;AAGjE,YAAM,QAAQ,IAAI,MAAM;AAAA,QACtB,QAAQ;AAAA,QACR,gBAAgB;AAAA,MAClB,CAAC;AAGD,UAAI,CAAC,0BAA0B,YAAY,GAAG;AAC5C,kCAA0B,YAAY,IAAI,CAAC;AAAA,MAC7C;AAEA,gCAA0B,YAAY,EAAE,WAAW,IAAI;AAEvD,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../src/lib/knock-client.ts","../package.json"],"sourcesContent":["import KnockMgmt from \"@knocklabs/mgmt\";\nimport { Knock } from \"@knocklabs/node\";\n\nimport pkg from \"../../package.json\";\nimport { Config } from \"../types.js\";\n\nconst serviceTokensToApiClients: Record<string, Record<string, Knock>> = {};\n\ntype KnockClient = ReturnType<typeof createKnockClient>;\n\n// Include a custom header to identify all client requests in the API logs\nconst knockClientHeaders = {\n \"X-Knock-Client\": `knock/agent-toolkit@${pkg.version}`,\n};\n\nconst createKnockClient = (config: Config) => {\n const serviceToken = config.serviceToken ?? process.env.KNOCK_SERVICE_TOKEN;\n\n if (!serviceToken) {\n throw new Error(\n \"Service token is required. Please set the `serviceToken` property in the config or the `KNOCK_SERVICE_TOKEN` environment variable.\"\n );\n }\n\n const client = new KnockMgmt({\n serviceToken,\n defaultHeaders: knockClientHeaders,\n });\n\n return Object.assign(client, {\n publicApi: async (environmentSlug?: string): Promise<Knock> => {\n const environment =\n environmentSlug ?? config.environment ?? \"development\";\n\n // If the client already exists for this service token and environment, return it\n if (serviceTokensToApiClients?.[serviceToken]?.[environment]) {\n return serviceTokensToApiClients[serviceToken][environment];\n }\n\n // Otherwise, fetch a public API key for this service token and environment\n const { api_key } = await client.apiKeys.exchange({ environment });\n\n // Create a new Knock client with the public API key\n const knock = new Knock({\n apiKey: api_key,\n defaultHeaders: knockClientHeaders,\n });\n\n // Store the client in the cache\n if (!serviceTokensToApiClients[serviceToken]) {\n serviceTokensToApiClients[serviceToken] = {};\n }\n\n serviceTokensToApiClients[serviceToken][environment] = knock;\n\n return knock;\n },\n });\n};\n\nexport { createKnockClient, type KnockClient };\n","{\n \"name\": \"@knocklabs/agent-toolkit\",\n \"version\": \"0.5.1\",\n \"description\": \"A toolkit for working with Knock in Agent workflows.\",\n \"main\": \"src/index.js\",\n \"scripts\": {\n \"build\": \"tsup --env.NODE_ENV production\",\n \"clean\": \"rimraf ./dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint src --ext .ts,.tsx\",\n \"lint:fix\": \"eslint src --ext .ts,.tsx --fix\",\n \"format\": \"prettier --write \\\"src/**/*.{ts,tsx}\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.{ts,tsx}\\\"\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"release\": \"npm run build && npm run release:publish && changeset tag\",\n \"release:publish\": \"npm publish --access public --tolerate-republish\"\n },\n \"author\": \"Knock\",\n \"license\": \"MIT\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \"./openai\": {\n \"types\": \"./dist/openai/index.d.ts\",\n \"default\": \"./dist/openai/index.js\"\n },\n \"./ai-sdk\": {\n \"types\": \"./dist/ai-sdk/index.d.ts\",\n \"default\": \"./dist/ai-sdk/index.js\"\n },\n \"./langchain\": {\n \"types\": \"./dist/langchain/index.d.ts\",\n \"default\": \"./dist/langchain/index.js\"\n },\n \"./mastra\": {\n \"types\": \"./dist/mastra/index.d.ts\",\n \"default\": \"./dist/mastra/index.js\"\n },\n \"./modelcontextprotocol\": {\n \"types\": \"./dist/modelcontextprotocol/index.d.ts\",\n \"default\": \"./dist/modelcontextprotocol/index.js\"\n },\n \"./human-in-the-loop\": {\n \"types\": \"./dist/human-in-the-loop/index.d.ts\",\n \"default\": \"./dist/human-in-the-loop/index.js\"\n },\n \"./types\": {\n \"types\": \"./dist/types.d.ts\"\n }\n },\n \"bin\": {\n \"local-mcp\": \"dist/modelcontextprotocol/local-server.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"dependencies\": {\n \"@knocklabs/mgmt\": \"^0.2.0\",\n \"@knocklabs/node\": \"^1.10.3\",\n \"@modelcontextprotocol/sdk\": \"^1.7.0\",\n \"@sentry/node\": \"^10.5.0\",\n \"json-schema-to-zod\": \"^2.6.1\",\n \"uuid\": \"^11.1.0\",\n \"yargs\": \"^17.7.2\",\n \"zod\": \"^3.24.2\",\n \"zod-to-json-schema\": \"^3.24.5\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.28.1\",\n \"@eslint/js\": \"^9.24.0\",\n \"@langchain/core\": \"^0.3.45\",\n \"@types/node\": \"^22.13.10\",\n \"@types/yargs\": \"^17.0.33\",\n \"@typescript-eslint/eslint-plugin\": \"^8.29.1\",\n \"@typescript-eslint/parser\": \"^8.29.1\",\n \"ai\": \"^4.2.8\",\n \"eslint\": \"^9.24.0\",\n \"eslint-config-prettier\": \"^10.1.2\",\n \"eslint-import-resolver-typescript\": \"^4.3.2\",\n \"eslint-plugin-import\": \"^2.31.0\",\n \"eslint-plugin-prettier\": \"^5.2.6\",\n \"openai\": \"^4.90.0\",\n \"prettier\": \"^3.5.3\",\n \"rimraf\": \"^6.0.1\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.8.2\",\n \"typescript-eslint\": \"^8.29.1\",\n \"vitest\": \"^1.3.1\"\n },\n \"peerDependencies\": {\n \"@mastra/core\": \"^0.10.3\",\n \"ai\": \"^4.0.0\",\n \"openai\": \"^4.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"ai\": {\n \"optional\": true\n }\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"],"mappings":";AAAA,OAAO,eAAe;AACtB,SAAS,aAAa;;;ACDtB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,SAAW;AAAA,IACT,OAAS;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,MAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,SAAW;AAAA,IACX,mBAAmB;AAAA,EACrB;AAAA,EACA,QAAU;AAAA,EACV,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,SAAW;AAAA,IACT,YAAY;AAAA,MACV,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,eAAe;AAAA,MACb,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACV,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,0BAA0B;AAAA,MACxB,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,uBAAuB;AAAA,MACrB,OAAS;AAAA,MACT,SAAW;AAAA,IACb;AAAA,IACA,WAAW;AAAA,MACT,OAAS;AAAA,IACX;AAAA,EACF;AAAA,EACA,KAAO;AAAA,IACL,aAAa;AAAA,EACf;AAAA,EACA,OAAS;AAAA,IACP;AAAA,EACF;AAAA,EACA,cAAgB;AAAA,IACd,mBAAmB;AAAA,IACnB,mBAAmB;AAAA,IACnB,6BAA6B;AAAA,IAC7B,gBA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eAAe;AAG3C,UAAI,4BAA4B,YAAY,IAAI,WAAW,GAAG;AAC5D,eAAO,0BAA0B,YAAY,EAAE,WAAW;AAAA,MAC5D;AAGA,YAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,QAAQ,SAAS,EAAE,YAAY,CAAC;AAGjE,YAAM,QAAQ,IAAI,MAAM;AAAA,QACtB,QAAQ;AAAA,QACR,gBAAgB;AAAA,MAClB,CAAC;AAGD,UAAI,CAAC,0BAA0B,YAAY,GAAG;AAC5C,kCAA0B,YAAY,IAAI,CAAC;AAAA,MAC7C;AAEA,gCAA0B,YAAY,EAAE,WAAW,IAAI;AAEvD,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createKnockClient
3
- } from "../chunk-PLL3H2Y6.js";
3
+ } from "../chunk-UBRPLPCX.js";
4
4
  import {
5
5
  getToolMap,
6
6
  getToolsByPermissionsInCategories
7
- } from "../chunk-WSJ5XINN.js";
7
+ } from "../chunk-3Q6IG57F.js";
8
8
  import {
9
9
  __commonJS,
10
10
  __export,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createKnockClient
3
- } from "../chunk-PLL3H2Y6.js";
3
+ } from "../chunk-UBRPLPCX.js";
4
4
  import {
5
5
  getToolMap,
6
6
  getToolsByPermissionsInCategories
7
- } from "../chunk-WSJ5XINN.js";
7
+ } from "../chunk-3Q6IG57F.js";
8
8
  import "../chunk-G3PMV62Z.js";
9
9
 
10
10
  // src/mastra/tool-converter.ts
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createKnockMcpServer
3
- } from "../chunk-LWVB2RKE.js";
4
- import "../chunk-WSJ5XINN.js";
3
+ } from "../chunk-OA5U6LZU.js";
4
+ import "../chunk-3Q6IG57F.js";
5
5
  import "../chunk-G3PMV62Z.js";
6
6
  export {
7
7
  createKnockMcpServer
@@ -1,20 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createKnockMcpServer
4
- } from "../chunk-LWVB2RKE.js";
4
+ } from "../chunk-OA5U6LZU.js";
5
5
  import {
6
6
  createKnockClient
7
- } from "../chunk-PLL3H2Y6.js";
7
+ } from "../chunk-UBRPLPCX.js";
8
8
  import {
9
9
  filterTools,
10
10
  tools
11
- } from "../chunk-WSJ5XINN.js";
11
+ } from "../chunk-3Q6IG57F.js";
12
12
  import "../chunk-G3PMV62Z.js";
13
13
 
14
14
  // src/modelcontextprotocol/local-server.ts
15
15
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
16
+ import * as Sentry from "@sentry/node";
16
17
  import { default as yargs } from "yargs";
17
18
  import { hideBin } from "yargs/helpers";
19
+
20
+ // config.ts
21
+ var SENTRY_DSN = "https://96631541e2f1d099b090e899572a807e@o605776.ingest.us.sentry.io/4509843669909504";
22
+
23
+ // src/modelcontextprotocol/local-server.ts
18
24
  var main = async () => {
19
25
  const {
20
26
  serviceToken,
@@ -64,12 +70,18 @@ var main = async () => {
64
70
  };
65
71
  const knockClient = createKnockClient(config);
66
72
  const filteredTools = patterns ? patterns.map((pattern) => filterTools(tools, pattern)).flat() : void 0;
67
- const mcpServer = await createKnockMcpServer({
73
+ Sentry.init({
74
+ dsn: SENTRY_DSN,
75
+ sendDefaultPii: false,
76
+ tracesSampleRate: 1
77
+ });
78
+ const knockServer = await createKnockMcpServer({
68
79
  config,
69
80
  knockClient,
70
81
  tools: filteredTools,
71
82
  workflows: workflowsAsTools
72
83
  });
84
+ const mcpServer = Sentry.wrapMcpServerWithSentry(knockServer);
73
85
  const transport = new StdioServerTransport();
74
86
  await mcpServer.connect(transport);
75
87
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/modelcontextprotocol/local-server.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { default as yargs } from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport { createKnockClient } from \"../lib/knock-client.js\";\nimport { tools } from \"../lib/tools/index.js\";\nimport { filterTools } from \"../lib/utils.js\";\nimport { Config } from \"../types.js\";\n\nimport { createKnockMcpServer } from \"./index.js\";\n\n/**\n * Main entry point for the Knock MCP server.\n * Runs as a standalone process, as defined in package.json#bin.\n * An entrypoint for this file exists in the tsup configuration of the package.\n */\nconst main = async () => {\n const {\n serviceToken,\n environment,\n userId,\n tenantId,\n tools: patterns,\n workflows: workflowsAsTools,\n } = await yargs(hideBin(process.argv))\n .version(\"0.1.0\")\n .option(\"tools\", {\n alias: \"t\",\n type: \"string\",\n array: true,\n description: `List of tools to enable. Use \"*\" to enable all tools. Use \"category\" or \"category.*\" to enable all tools from a category. Use \"category.toolName\" to pick a single tool. Available categories: ${Object.keys(\n tools\n )}`,\n })\n .option(\"workflows\", {\n type: \"string\",\n array: true,\n description: `List of workflows to enable as tools in the MCP server. By default no workflows are enabled. Pass a list of workflow keys to enable those workflows as tools.`,\n })\n .option(\"service-token\", {\n alias: \"st\",\n type: \"string\",\n description: `Knock service token. Only supply this if you're not passing it via the \\`KNOCK_SERVICE_TOKEN\\` environment variable.`,\n demandOption: false,\n })\n .option(\"environment\", {\n alias: \"e\",\n type: \"string\",\n description: `The environment to operate in from your Knock account`,\n })\n .option(\"user-id\", {\n type: \"string\",\n description: `The user id to operate as`,\n })\n .option(\"tenant-id\", {\n type: \"string\",\n description: `The tenant id to operate as`,\n })\n .parse();\n\n const SERVICE_TOKEN = serviceToken || process.env.KNOCK_SERVICE_TOKEN;\n\n if (!SERVICE_TOKEN) {\n throw new Error(\n \"Knock service token is required. You should set it via the `KNOCK_SERVICE_TOKEN` environment variable.\"\n );\n }\n\n const config: Config = {\n serviceToken: SERVICE_TOKEN,\n userId,\n tenantId,\n environment,\n };\n\n const knockClient = createKnockClient(config);\n\n const filteredTools = patterns\n ? patterns.map((pattern) => filterTools(tools, pattern)).flat()\n : undefined;\n\n const mcpServer = await createKnockMcpServer({\n config,\n knockClient,\n tools: filteredTools,\n workflows: workflowsAsTools,\n });\n\n const transport = new StdioServerTransport();\n await mcpServer.connect(transport);\n};\n\nmain().catch((error) => {\n console.error(\"\\nKnock: Error initializing MCP server:\\n\", error.message);\n});\n"],"mappings":";;;;;;;;;;;;;;AAEA,SAAS,4BAA4B;AACrC,SAAS,WAAW,aAAa;AACjC,SAAS,eAAe;AAcxB,IAAM,OAAO,YAAY;AACvB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,WAAW;AAAA,EACb,IAAI,MAAM,MAAM,QAAQ,QAAQ,IAAI,CAAC,EAClC,QAAQ,OAAO,EACf,OAAO,SAAS;AAAA,IACf,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa,kMAAkM,OAAO;AAAA,MACpN;AAAA,IACF,CAAC;AAAA,EACH,CAAC,EACA,OAAO,aAAa;AAAA,IACnB,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa;AAAA,EACf,CAAC,EACA,OAAO,iBAAiB;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,IACb,cAAc;AAAA,EAChB,CAAC,EACA,OAAO,eAAe;AAAA,IACrB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC,EACA,OAAO,WAAW;AAAA,IACjB,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC,EACA,OAAO,aAAa;AAAA,IACnB,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC,EACA,MAAM;AAET,QAAM,gBAAgB,gBAAgB,QAAQ,IAAI;AAElD,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAiB;AAAA,IACrB,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,cAAc,kBAAkB,MAAM;AAE5C,QAAM,gBAAgB,WAClB,SAAS,IAAI,CAAC,YAAY,YAAY,OAAO,OAAO,CAAC,EAAE,KAAK,IAC5D;AAEJ,QAAM,YAAY,MAAM,qBAAqB;AAAA,IAC3C;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,WAAW;AAAA,EACb,CAAC;AAED,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,UAAU,QAAQ,SAAS;AACnC;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,6CAA6C,MAAM,OAAO;AAC1E,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/modelcontextprotocol/local-server.ts","../../config.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport * as Sentry from \"@sentry/node\";\nimport { default as yargs } from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport { SENTRY_DSN } from \"@config\";\n\nimport { createKnockClient } from \"../lib/knock-client.js\";\nimport { tools } from \"../lib/tools/index.js\";\nimport { filterTools } from \"../lib/utils.js\";\nimport { Config } from \"../types.js\";\n\nimport { createKnockMcpServer } from \"./index.js\";\n\n/**\n * Main entry point for the Knock MCP server.\n * Runs as a standalone process, as defined in package.json#bin.\n * An entrypoint for this file exists in the tsup configuration of the package.\n */\nconst main = async () => {\n const {\n serviceToken,\n environment,\n userId,\n tenantId,\n tools: patterns,\n workflows: workflowsAsTools,\n } = await yargs(hideBin(process.argv))\n .version(\"0.1.0\")\n .option(\"tools\", {\n alias: \"t\",\n type: \"string\",\n array: true,\n description: `List of tools to enable. Use \"*\" to enable all tools. Use \"category\" or \"category.*\" to enable all tools from a category. Use \"category.toolName\" to pick a single tool. Available categories: ${Object.keys(\n tools\n )}`,\n })\n .option(\"workflows\", {\n type: \"string\",\n array: true,\n description: `List of workflows to enable as tools in the MCP server. By default no workflows are enabled. Pass a list of workflow keys to enable those workflows as tools.`,\n })\n .option(\"service-token\", {\n alias: \"st\",\n type: \"string\",\n description: `Knock service token. Only supply this if you're not passing it via the \\`KNOCK_SERVICE_TOKEN\\` environment variable.`,\n demandOption: false,\n })\n .option(\"environment\", {\n alias: \"e\",\n type: \"string\",\n description: `The environment to operate in from your Knock account`,\n })\n .option(\"user-id\", {\n type: \"string\",\n description: `The user id to operate as`,\n })\n .option(\"tenant-id\", {\n type: \"string\",\n description: `The tenant id to operate as`,\n })\n .parse();\n\n const SERVICE_TOKEN = serviceToken || process.env.KNOCK_SERVICE_TOKEN;\n\n if (!SERVICE_TOKEN) {\n throw new Error(\n \"Knock service token is required. You should set it via the `KNOCK_SERVICE_TOKEN` environment variable.\"\n );\n }\n\n const config: Config = {\n serviceToken: SERVICE_TOKEN,\n userId,\n tenantId,\n environment,\n };\n\n const knockClient = createKnockClient(config);\n\n const filteredTools = patterns\n ? patterns.map((pattern) => filterTools(tools, pattern)).flat()\n : undefined;\n\n Sentry.init({\n dsn: SENTRY_DSN,\n sendDefaultPii: false,\n tracesSampleRate: 1.0,\n });\n\n const knockServer = await createKnockMcpServer({\n config,\n knockClient,\n tools: filteredTools,\n workflows: workflowsAsTools,\n });\n\n const mcpServer = Sentry.wrapMcpServerWithSentry(knockServer);\n const transport = new StdioServerTransport();\n await mcpServer.connect(transport);\n};\n\nmain().catch((error) => {\n console.error(\"\\nKnock: Error initializing MCP server:\\n\", error.message);\n});\n","export const SENTRY_DSN =\n \"https://96631541e2f1d099b090e899572a807e@o605776.ingest.us.sentry.io/4509843669909504\";\n"],"mappings":";;;;;;;;;;;;;;AAEA,SAAS,4BAA4B;AACrC,YAAY,YAAY;AACxB,SAAS,WAAW,aAAa;AACjC,SAAS,eAAe;;;ACLjB,IAAM,aACX;;;ADoBF,IAAM,OAAO,YAAY;AACvB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,WAAW;AAAA,EACb,IAAI,MAAM,MAAM,QAAQ,QAAQ,IAAI,CAAC,EAClC,QAAQ,OAAO,EACf,OAAO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AQ,MAAM,6CAA6C,MAAM,OAAO;AAC1E,CAAC;","names":[]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createKnockClient
3
- } from "../chunk-PLL3H2Y6.js";
3
+ } from "../chunk-UBRPLPCX.js";
4
4
  import {
5
5
  getToolMap,
6
6
  getToolsByPermissionsInCategories
7
- } from "../chunk-WSJ5XINN.js";
7
+ } from "../chunk-3Q6IG57F.js";
8
8
  import "../chunk-G3PMV62Z.js";
9
9
 
10
10
  // src/openai/tool-converter.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/agent-toolkit",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "A toolkit for working with Knock in Agent workflows.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -59,6 +59,7 @@
59
59
  "@knocklabs/mgmt": "^0.2.0",
60
60
  "@knocklabs/node": "^1.10.3",
61
61
  "@modelcontextprotocol/sdk": "^1.7.0",
62
+ "@sentry/node": "^10.5.0",
62
63
  "json-schema-to-zod": "^2.6.1",
63
64
  "uuid": "^11.1.0",
64
65
  "yargs": "^17.7.2",
@@ -89,9 +90,9 @@
89
90
  "vitest": "^1.3.1"
90
91
  },
91
92
  "peerDependencies": {
93
+ "@mastra/core": "^0.10.3",
92
94
  "ai": "^4.0.0",
93
- "openai": "^4.0.0",
94
- "@mastra/core": "^0.10.3"
95
+ "openai": "^4.0.0"
95
96
  },
96
97
  "peerDependenciesMeta": {
97
98
  "ai": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/knock-tool.ts","../src/lib/tools/channels.ts","../src/lib/tools/commits.ts","../src/lib/tools/documentation.ts","../src/lib/tools/email-layouts.ts","../src/lib/tools/environments.ts","../src/lib/tools/guides.ts","../src/lib/tools/shared.ts","../src/lib/tools/message-types.ts","../src/lib/tools/messages.ts","../src/lib/tools/objects.ts","../src/lib/tools/partials.ts","../src/lib/tools/tenants.ts","../src/lib/tools/users.ts","../src/lib/tools/workflows-as-tools.ts","../src/lib/utils.ts","../src/lib/tools/workflows.ts","../src/lib/tools/workflow-steps.ts","../src/lib/tools/index.ts"],"sourcesContent":["import type { ZodObject } from \"zod\";\nimport { z } from \"zod\";\n\nimport { Config } from \"../types.js\";\n\nimport { KnockClient } from \"./knock-client.js\";\n\nexport interface KnockToolDefinition {\n /**\n * The method name of the tool. This is a machine-readable string.\n */\n method: string;\n /**\n * The name of the tool. This can be used to reference the tool in the code.\n * A descriptive LLM-readable string.\n */\n name: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, including examples where useful.\n */\n description: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, usage and input parameters.\n * Ths is intended to be used by the underlying LLM.\n */\n fullDescription: string;\n\n /**\n * The Zod schema for the input parameters of the tool\n */\n parameters?: ZodObject<any>;\n /**\n * The actual implementation of the tool.\n */\n execute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nexport interface KnockTool extends Omit<KnockToolDefinition, \"execute\"> {\n bindExecute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nconst trimLines = (text: string) =>\n text\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter(Boolean)\n .join(\"\\n\");\n\nexport const KnockTool = (\n args: Omit<KnockToolDefinition, \"fullDescription\">\n): KnockTool => {\n const { execute, ...restOfArgs } = args;\n const parameters = restOfArgs.parameters\n ? restOfArgs.parameters\n : z.object({});\n\n const schemaEntries = Object.entries(parameters.shape);\n\n const argsStr =\n schemaEntries.length === 0\n ? \"Takes no arguments\"\n : schemaEntries\n .map(([key, value]) => {\n return `- ${key}: ${(value as any).description || \"\"}`;\n })\n .join(\"\\n\");\n\n const fullDescription = trimLines(`\n Tool name:\n ${args.name}\n Description:\n ${args.description}.\n Arguments:\n ${argsStr}\n `);\n\n return {\n ...restOfArgs,\n parameters,\n fullDescription,\n bindExecute:\n (knockClient: KnockClient, config: Config) => async (input: any) => {\n try {\n return await execute(knockClient, config)(input);\n } catch (error: unknown) {\n console.error(error);\n\n if (error instanceof Error) {\n return {\n message: `An error occurred with the call to the Knock API: ${error.message}`,\n error,\n };\n }\n\n return {\n message:\n \"An unknown error occurred with the call to the Knock API.\",\n error,\n };\n }\n },\n };\n};\n","import { Channel } from \"@knocklabs/mgmt/resources/channels.js\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the Channel resource that is easier to work with in the LLM.\n */\ntype SerializedChannel = {\n key: string;\n name: string;\n type: string;\n provider: string;\n};\n\nfunction serializeChannelResponse(channel: Channel): SerializedChannel {\n return {\n key: channel.key,\n name: channel.name,\n type: channel.type,\n provider: channel.provider,\n };\n}\n\nconst listChannels = KnockTool({\n method: \"list_channels\",\n name: \"List channels\",\n description: `\n Returns a list of all of the channels configured in the account. Each channel returns information about the type of channel it is (email, sms, push, etc), and the provider that's used to power the channel. Channels can be used across all environments.\n\n Use this tool when you need to know about the channels configured in the Knock account, like when configuring a workflow.\n `,\n execute: (knockClient) => async (_params) => {\n const allChannels: SerializedChannel[] = [];\n for await (const channel of knockClient.channels.list()) {\n allChannels.push(serializeChannelResponse(channel));\n }\n return allChannels;\n },\n});\n\nexport const channels = {\n listChannels,\n};\n\nexport const permissions = {\n read: [\"listChannels\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listCommits = KnockTool({\n method: \"list_commits\",\n name: \"List commits\",\n description: `\n Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list commits for. Defaults to `development`.\"\n ),\n promoted: z\n .boolean()\n .describe(\n \"(boolean): Whether to only return promoted commits. Defaults to `false`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.list({\n environment: params.environment ?? config.environment ?? \"development\",\n promoted: params.promoted ?? false,\n });\n },\n});\n\nconst commitAllChanges = KnockTool({\n method: \"commit_all_changes\",\n name: \"Commit all changes\",\n description: `\n Commit all pending changes. This can only be used in the development environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to commit all changes to. Defaults to `development`.\"\n ),\n message: z\n .string()\n .optional()\n .describe(\"(string): The message to include in the commit.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.commitAll({\n environment: params.environment ?? config.environment ?? \"development\",\n commit_message: params.message,\n });\n },\n});\n\nconst promoteAllCommits = KnockTool({\n method: \"promote_all_commits\",\n name: \"Promote all commits\",\n description: `\n Promote all commits to the next environment. Use this tool when you are asked to deploy all changes.\n `,\n parameters: z.object({\n toEnvironment: z\n .string()\n .describe(\"(string): The environment to promote all commits to.\"),\n }),\n execute: (knockClient, _config) => async (params) => {\n return await knockClient.put(\"/v1/commits/promote\", {\n body: { to_environment: params.toEnvironment },\n });\n },\n});\n\nexport const commits = {\n listCommits,\n commitAllChanges,\n promoteAllCommits,\n};\n\nexport const permissions = {\n read: [\"listCommits\"],\n manage: [\"commitAllChanges\", \"promoteAllCommits\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst searchDocumentation = KnockTool({\n method: \"search_documentation\",\n name: \"Search documentation\",\n description: \"Search the Knock documentation for a given query\",\n parameters: z.object({\n query: z.string().describe(\"The query to search the documentation for\"),\n }),\n execute: () => async (params) => {\n const response = await fetch(`https://docs.knock.app/api/search`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ query: params.query }),\n });\n\n const data = await response.json();\n return data;\n },\n});\n\nexport const documentation = {\n searchDocumentation,\n};\n\nexport const permissions = {\n read: [\"searchDocumentation\"],\n};\n","import { EmailLayout } from \"@knocklabs/mgmt/resources/email-layouts.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the EmailLayout resource that is easier to work with in the LLM.\n */\ntype SerializedEmailLayout = {\n key: string;\n name: string;\n htmlContent: string;\n textContent: string;\n};\n\nfunction serializeEmailLayoutResponse(\n emailLayout: EmailLayout\n): SerializedEmailLayout {\n return {\n key: emailLayout.key,\n name: emailLayout.name,\n htmlContent: emailLayout.html_layout,\n textContent: emailLayout.text_layout,\n };\n}\n\nconst listEmailLayouts = KnockTool({\n method: \"list_email_layouts\",\n name: \"List email layouts\",\n description: `List all email layouts within the environment given. Returns information about the email layout, including the name and the key. \n \n Use this tool when building a workflow that is building an email notification when you need to know the available email layouts.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list email layouts for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allEmailLayouts: SerializedEmailLayout[] = [];\n for await (const emailLayout of knockClient.emailLayouts.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allEmailLayouts.push(serializeEmailLayoutResponse(emailLayout));\n }\n return allEmailLayouts;\n },\n});\n\nconst createOrUpdateEmailLayout = KnockTool({\n method: \"upsert_email_layout\",\n name: \"Create or update email layout\",\n description: `Create or update a new email layout within the environment given. Use this tool when you need to define shared pieces of content across multiple email templates, like a header/footer. The email layout will be used to render the email template.\n\n Here are the rules for creating an email layout:\n\n - Every email layout must have a \\`{{ content }}\\` tag. This is where the content of the email will be injected.\n - You must set both an HTML and text version of the email layout.\n - CSS should be included in the HTML version of the email layout under <style> tags.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the email layout for. Defaults to `development`.\"\n ),\n key: z\n .string()\n .describe(\"(string): The key of the email layout to create or update.\"),\n name: z.string().describe(\"(string): The name of the email layout.\"),\n htmlContent: z\n .string()\n .describe(\"(string): The HTML content of the email layout.\"),\n textContent: z\n .string()\n .describe(\"(string): The text content of the email layout.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const response = await knockClient.emailLayouts.upsert(params.key, {\n environment: params.environment ?? config.environment ?? \"development\",\n email_layout: {\n name: params.name,\n html_layout: params.htmlContent,\n text_layout: params.textContent,\n },\n });\n\n return serializeEmailLayoutResponse(response.email_layout);\n },\n});\n\nexport const emailLayouts = {\n listEmailLayouts,\n createOrUpdateEmailLayout,\n};\n\nexport const permissions = {\n read: [\"listEmailLayouts\"],\n manage: [\"createOrUpdateEmailLayout\"],\n};\n","import { Environment } from \"@knocklabs/mgmt/resources/environments.js\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the Environment resource that is easier to work with in the LLM.\n */\ntype SerializedEnvironment = {\n slug: string;\n name: string;\n};\n\nfunction serializeEnvironmentResponse(\n environment: Environment\n): SerializedEnvironment {\n return {\n slug: environment.slug,\n name: environment.name,\n };\n}\n\nconst listEnvironments = KnockTool({\n method: \"list_environments\",\n name: \"List environments\",\n description: `\n Lists all environments available, returning the slug and name of each environment. Use this tool when you need to see what environments are available.\n `,\n execute: (knockClient) => async (_params) => {\n const allEnvironments: SerializedEnvironment[] = [];\n for await (const environment of knockClient.environments.list()) {\n allEnvironments.push(serializeEnvironmentResponse(environment));\n }\n return allEnvironments;\n },\n});\n\nexport const environments = {\n listEnvironments,\n};\n\nexport const permissions = {\n read: [\"listEnvironments\"],\n};\n","import { Guide } from \"@knocklabs/mgmt/resources.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nimport { conditionSchema } from \"./shared.js\";\n\n/**\n * A slimmed down version of the Guide resource that is easier to work with in the LLM.\n */\ntype SerializedGuide = Pick<\n Guide,\n \"key\" | \"name\" | \"description\" | \"type\" | \"active\"\n> & {\n steps: {\n ref: string;\n name: string;\n schemaKey: string;\n schemaVariantKey: string;\n schemaContent?: Record<string, any>;\n }[];\n};\n\nfunction serializeGuide(guide: Guide): SerializedGuide {\n return {\n key: guide.key,\n name: guide.name,\n description: guide.description,\n type: guide.type,\n active: guide.active,\n steps: (guide.steps ?? []).map((step) => ({\n ref: step.ref,\n name: step.name!,\n schemaKey: step.schema_key,\n schemaVariantKey: step.schema_variant_key,\n schemaContent: step.values,\n })),\n };\n}\n\nconst listGuides = KnockTool({\n method: \"list_guides\",\n name: \"List guides\",\n description: `\n List all guides available for the given environment. Returns structural information about the guides, including the key, name, description, type, and status.\n\n Use this tool when you need to understand which guides are available in the environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list guides for. Defaults to `development`.\"\n ),\n page_size: z\n .number()\n .optional()\n .describe(\"(number): The number of guides to return per page.\"),\n after: z\n .string()\n .optional()\n .describe(\"(string): The cursor to use for pagination.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const allGuides: SerializedGuide[] = [];\n const listParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n page_size: params.page_size,\n after: params.after,\n };\n for await (const guide of knockClient.guides.list(listParams)) {\n allGuides.push(serializeGuide(guide));\n }\n return allGuides;\n },\n});\n\nconst getGuide = KnockTool({\n method: \"get_guide\",\n name: \"Get guide\",\n description: `\n Get a guide by its key. Returns structural information about the guide, including the key, name, description, type, and status.\n\n Use this tool when you need to retrieve information about a specific guide.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the guide for. Defaults to `development`.\"\n ),\n guideKey: z.string().describe(\"(string): The key of the guide to get.\"),\n hide_uncommitted_changes: z\n .boolean()\n .optional()\n .describe(\n \"(boolean): Whether to hide uncommitted changes and return only published version.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const guide = await knockClient.guides.retrieve(params.guideKey, {\n environment: params.environment ?? config.environment ?? \"development\",\n hide_uncommitted_changes: params.hide_uncommitted_changes,\n });\n return serializeGuide(guide);\n },\n});\n\nconst createOrUpdateGuide = KnockTool({\n method: \"upsert_guide\",\n name: \"Upsert guide\",\n description: `\n Create or update a guide. A guide defines an in-app guide that can be displayed to users based on priority and other conditions.\n\n Use this tool when you need to create a new guide or update an existing one. The guide will be created with the specified configuration.\n\n Note: This endpoint only operates on guides in the \"development\" environment.\n\n ## Guide step schema\n\n When working with guide steps, you must use a \\`schemaKey\\` and \\`schemaVariantKey\\` to reference the message type schema that the step's content conforms to. You can use the \\`list_message_types\\` tool to get a list of available message types and the available variants for that message type.\n\n You **must** supply a \\`schemaContent\\` that sets the content for each of the fields in the \\`fields\\` object inside of the message type schema variant you select.\n \n For example, if you have a message type schema with a \\`fields\\` object that looks like this:\n\n \\`\\`\\`json\n {\n \"fields\": {\n \"title\": {\n \"type\": \"string\",\n \"required\": true\n }\n }\n }\n \\`\\`\\`\n\n You would need to supply a \\`schemaContent\\` that looks like this:\n\n \\`\\`\\`json\n {\n \"title\": \"Hello, world!\"\n }\n \\`\\`\\`\n\n ### Guide targeting\n\n By default, a guide will target all users. If you want to target users with specific attributes, you can use \\`targetPropertyConditions\\` to describe the targeting conditions.\n\n When using targeting conditions, you can use the following properties:\n\n - \\`recipient\\`: Use a property on the recipient\n - \\`data\\`: Use data coming from the application\n - \\`tenant\\`: Use a property on the tenant\n\n For example, if you want to target users with the email \\`john.doe@example.com\\`, you would supply the following targeting conditions:\n\n \\`\\`\\`json\n [\n { \"operator\": \"equal_to\", \"value\": \"john.doe@example.com\", \"argument\": \"recipient.email\" }\n ]\n \\`\\`\\`\n\n ### Activation location rules\n\n You can supply a list of activation location rules to describe where in your application the guide should be shown. Each activation rule is a directive that describes whether the guide should be shown or hidden based on the pathname of the page.\n\n For example, if you want to show the guide on all pages except for the \\`admin\\` path, you would supply the following activation location rules:\n\n \\`\\`\\`json\n [\n { \"directive\": \"allow\", \"pathname\": \"*\" },\n { \"directive\": \"block\", \"pathname\": \"/admin\" }\n ]\n \\`\\`\\`\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to upsert the guide for. Defaults to `development`.\"\n ),\n guideKey: z\n .string()\n .describe(\n \"(string): The key of the guide to upsert. Must be at minimum 3 characters and at maximum 255 characters in length. Must be in the format of ^[a-z0-9_-]+$.\"\n ),\n name: z\n .string()\n .describe(\n \"(string): A name for the guide. Must be at maximum 255 characters in length.\"\n ),\n channelKey: z\n .string()\n .optional()\n .describe(\n \"(string): The key of the channel in which the guide exists. Defaults to `knock-guide`.\"\n )\n .default(\"knock-guide\"),\n description: z\n .string()\n .optional()\n .describe(\n \"(string): An arbitrary string attached to a guide object. Maximum of 280 characters allowed.\"\n ),\n step: z\n .object({\n name: z\n .string()\n .describe(\"(string): The name of the step.\")\n .optional()\n .default(\"Default\"),\n ref: z\n .string()\n .describe(\"(string): The unique identifier of the step.\")\n .optional()\n .default(\"default\"),\n schemaKey: z\n .string()\n .describe(\n \"(string): The key of the schema that the step's content conforms to.\"\n ),\n schemaVariantKey: z\n .string()\n .describe(\n \"(string): The key of the schema variant that the step's content conforms to.\"\n )\n .optional()\n .default(\"default\"),\n schemaContent: z\n .record(z.string(), z.any())\n .describe(\n \"(object): A map of values that make up the step's content. Each value must conform to its respective template schema field settings.\"\n ),\n })\n .describe(\"(object): The guide step to upsert.\"),\n targetPropertyConditions: z\n .array(conditionSchema)\n .describe(\n \"(array): A list of property conditions that describe the target audience for the guide. Conditions are joined as AND operations.\"\n ),\n activationLocationRules: z\n .array(\n z.object({\n directive: z\n .enum([\"allow\", \"block\"])\n .describe(\n \"(string): The directive to apply to the activation location rule (allow or block).\"\n ),\n pathname: z\n .string()\n .describe(\n \"(string): The pathname to target. Should correspond to a URI in your application.\"\n ),\n })\n )\n .describe(\n \"(array): A list of activation location rules that describe where in your application the guide should be shown.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n // Attempt to fetch the message type to ensure it exists\n const messageType = await knockClient.messageTypes.retrieve(\n params.step.schemaKey,\n {\n environment: params.environment ?? config.environment ?? \"development\",\n }\n );\n\n // Ensure that the schema variant exists\n const schemaVariant = messageType.variants.find(\n (variant) => variant.key === params.step.schemaVariantKey\n );\n\n if (!schemaVariant) {\n throw new Error(\n `Schema variant ${params.step.schemaVariantKey} not found in message type ${messageType.key}`\n );\n }\n\n const result = await knockClient.guides.upsert(params.guideKey, {\n environment: params.environment ?? config.environment ?? \"development\",\n guide: {\n name: params.name,\n description: params.description,\n channel_key: params.channelKey ?? \"knock-guide\",\n steps: [\n {\n ref: params.step.ref ?? \"default\",\n schema_key: messageType.key,\n schema_semver: messageType.semver,\n schema_variant_key: schemaVariant.key,\n values: params.step.schemaContent,\n },\n ],\n target_property_conditions: {\n all: params.targetPropertyConditions,\n },\n activation_location_rules: params.activationLocationRules,\n },\n });\n\n return serializeGuide(result.guide);\n },\n});\n\nexport const guides = {\n listGuides,\n getGuide,\n createOrUpdateGuide,\n};\n\nexport const permissions = {\n read: [\"listGuides\", \"getGuide\"],\n manage: [\"createOrUpdateGuide\"],\n};\n","import { z } from \"zod\";\n\nconst recipientSchema = z\n .union([\n z.string().describe(\"A user ID (string).\"),\n z\n .object({ id: z.string(), collection: z.string() })\n .describe(\"A reference to an object in a collection.\"),\n ])\n .describe(\n \"A recipient can be a user ID or a reference to an object in a collection.\"\n );\n\nconst conditionSchema = z\n .object({\n operator: z\n .enum([\n \"equal_to\",\n \"not_equal_to\",\n \"greater_than\",\n \"less_than\",\n \"greater_than_or_equal_to\",\n \"less_than_or_equal_to\",\n \"contains\",\n \"not_contains\",\n \"contains_all\",\n \"empty\",\n \"not_empty\",\n ])\n .describe(\"(string): The operator to apply to the argument.\"),\n value: z.any().describe(\"(any): The value of the condition.\"),\n argument: z\n .string()\n .optional()\n .describe(\n \"(string): The argument of the condition. Can be empty when using empty or not_empty operators.\"\n ),\n })\n .describe(\"(object): A condition.\");\n\nexport { conditionSchema, recipientSchema };\n","import { MessageType } from \"@knocklabs/mgmt/resources/message-types.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the MessageType resource that is easier to work with in the LLM.\n */\ntype SerializedMessageType = {\n key: string;\n name: string;\n description?: string | null;\n variants: string[];\n};\n\nfunction serializeMessageTypeResponse(\n messageType: MessageType\n): SerializedMessageType {\n return {\n key: messageType.key,\n name: messageType.name,\n description: messageType.description,\n variants: messageType.variants.map((variant) => variant.key),\n };\n}\nconst listMessageTypes = KnockTool({\n method: \"list_message_types\",\n name: \"List message types\",\n description:\n \"List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list message types for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allMessageTypes: SerializedMessageType[] = [];\n for await (const messageType of knockClient.messageTypes.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allMessageTypes.push(serializeMessageTypeResponse(messageType));\n }\n return allMessageTypes;\n },\n});\n\nconst createOrUpdateMessageType = KnockTool({\n method: \"upsert_message_type\",\n name: \"Create or update message type\",\n description: `\n Create or update a message type. A message type is a schema that defines fields available to an editor within Knock. Message types always have at least one variant, that MUST be named \"default\". Use this tool when you need to create a new message type, or update an existing message type.\n\n ## Schema and fields\n\n The schema defines the fields available to an editor within Knock. A variant should have at least one field. Fields can be of different types, including: text, markdown, select, multi-select, image, and button.\n\n Each field must have a key, label, and type. Some fields like \\`select\\` and \\`multi_select\\` have additional settings that can be used to configure the field.\n\n <example>\n {\n \"key\": \"text\",\n \"label\": \"Text\",\n \"type\": \"text\",\n </example>\n\n <example>\n {\n \"key\": \"select\",\n \"label\": \"Select\",\n \"type\": \"select\",\n \"settings\": {\n \"options\": [\n {\n \"value\": \"option1\",\n \"label\": \"Option 1\",\n },\n ],\n },\n }\n </example>\n\n ## Preview templates\n\n The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named \"text\" will be rendered as {{ text }}. All fields should be included in the preview.\n\n You can make an educated guess as to what the preview template should look like based on the name of the message type and the fields. You can use plain CSS to style the preview by supplying a style tag in the preview. Use simple selectors like .class-name to style elements.\n\n <example>\n {\n \"preview\": \"<style>div { color: red; }</style>\\n<div>Hello there, {{ text }}</div>\"\n }\n </example>\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the message type in. Defaults to `development`.\"\n ),\n messageTypeKey: z\n .string()\n .describe(\"(string): The key of the message type to create or update.\"),\n name: z.string().describe(\"(string): The name of the message type.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the message type.\"),\n preview: z\n .string()\n .optional()\n .describe(\n \"(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants.\"\n ),\n variants: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the variant.\"),\n name: z.string().describe(\"(string): The name of the variant.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the variant.\"),\n fields: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the field.\"),\n type: z\n .string()\n .describe(\n \"(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`, `image`.\"\n ),\n label: z.string().describe(\"(string): The label of the field.\"),\n settings: z\n .object({})\n .optional()\n .describe(\"(object): The settings of the field.\"),\n })\n )\n .describe(\"(array): The fields of the variant.\"),\n })\n )\n .describe(\"(array): The variants of the message type.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.messageTypes.upsert(params.messageTypeKey, {\n message_type: {\n name: params.name,\n variants: params.variants,\n description: params.description ?? \"\",\n preview: params.preview ?? \"<div></div>\",\n },\n environment: params.environment ?? config.environment ?? \"development\",\n });\n },\n});\n\nexport const messageTypes = {\n listMessageTypes,\n createOrUpdateMessageType,\n};\n\nexport const permissions = {\n read: [\"listMessageTypes\"],\n manage: [\"createOrUpdateMessageType\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getMessageContent = KnockTool({\n method: \"get_message_content\",\n name: \"Get message content\",\n description: `\n Retrieves the complete contents of a single message, specified by the messageId. The message contents includes the rendered template that was sent to the recipient. Use this tool when you want to surface information about the emails, SMS, and push notifications that were sent to a user.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the message from. Defaults to `development`.\"\n ),\n messageId: z\n .string()\n .describe(\"(string): The messageId of the message to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.messages.getContent(params.messageId);\n },\n});\n\nexport const messages = {\n getMessageContent,\n};\n\nexport const permissions = {\n read: [\"getMessageContent\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listObjects = KnockTool({\n method: \"list_objects\",\n name: \"List objects\",\n description:\n \"List all objects in a single collection. Objects are used to model custom collections in Knock that are NOT users or tenants. Use this tool when you need to return a paginated list of objects in a single collection.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list objects from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to list objects from.\"),\n }),\n execute: (knockClient, _config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.list(params.collection);\n },\n});\n\nconst getObject = KnockTool({\n method: \"get_object\",\n name: \"Get object\",\n description:\n \"Get an object wihin a collection. Returns information about the object including any custom properties. Use this tool when you need to retrieve an object to understand it's properties.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the object from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to get the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to get.\"),\n }),\n execute: (knockClient, _config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.get(params.collection, params.objectId);\n },\n});\n\nconst createOrUpdateObject = KnockTool({\n method: \"upsert_object\",\n name: \"Create or update object\",\n description: `Create or update an object in a specific collection. Objects are used to model custom collections in Knock that are NOT users or tenants. If the object does not exist, it will be created. If the object exists, it will be updated with the provided properties. The update will always perform an upsert operation, so you do not need to provide the full properties each time.\n \n Use this tool when you need to create a new object, or update an existing custom-object. Custom objects can be used to subscribe users' to as lists, and also send non-user facing notifications to.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the object in. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to create or update the object in.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to create or update.\"),\n properties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): The properties to set on the object.\"),\n }),\n execute: (knockClient, _config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.set(\n params.collection,\n params.objectId,\n params.properties\n );\n },\n});\n\nconst subscribeUsersToObject = KnockTool({\n method: \"subscribe_users_to_object\",\n name: \"Subscribe users to object\",\n description: `\n Subscribe a list of users to an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to subscribe one or more users to an object where you will then trigger workflows for those lists of users to send notifications to.\n\n Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to subscribe the user to. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to subscribe the user to.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to subscribe the user to.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.addSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nconst unsubscribeUsersFromObject = KnockTool({\n method: \"unsubscribe_users_from_object\",\n name: \"Unsubscribe users from object\",\n description: `Unsubscribe a list of users from an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to unsubscribe one or more users from an object where you will then trigger workflows for those lists of users to send notifications to.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to unsubscribe the user from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to unsubscribe the user from.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to unsubscribe the user from.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to unsubscribe from the object.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.deleteSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nexport const objects = {\n listObjects,\n getObject,\n createOrUpdateObject,\n subscribeUsersToObject,\n unsubscribeUsersFromObject,\n};\n\nexport const permissions = {\n read: [\"listObjects\", \"getObject\"],\n manage: [\n \"createOrUpdateObject\",\n \"subscribeUsersToObject\",\n \"unsubscribeUsersFromObject\",\n ],\n};\n","import { Partial } from \"@knocklabs/mgmt/resources/partials.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"@/lib/knock-tool.js\";\n\n/**\n * A slimmed down version of the Partial resource that is easier to work with in the LLM.\n */\ntype SerializedPartial = {\n key: string;\n type: Partial[\"type\"];\n name: string;\n description?: string;\n};\n\nfunction serializePartial(partial: Partial): SerializedPartial {\n return {\n key: partial.key,\n type: partial.type,\n name: partial.name,\n description: partial.description,\n };\n}\n\nconst listPartials = KnockTool({\n method: \"list_partials\",\n name: \"List partials\",\n description: `\n List all partials within the environment given. Partials provide common building blocks for notification templates. Returns information about the partial, including the name and the key. \n Use this tool when you need to know the available partials for the environment, like when building a notification template and wanting to use a partial to build the template.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list partials for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allPartials: SerializedPartial[] = [];\n for await (const partial of knockClient.partials.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allPartials.push(serializePartial(partial));\n }\n return allPartials;\n },\n});\n\nconst getPartial = KnockTool({\n method: \"get_partial\",\n name: \"Get partial\",\n description: `\n Get a partial by its key. Use this tool when you need to know if a specific partial exists by key.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the partial for. Defaults to `development`.\"\n ),\n key: z.string().describe(\"(string): The key of the partial to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const partial = await knockClient.partials.retrieve(params.key, {\n environment: params.environment ?? config.environment ?? \"development\",\n });\n\n return serializePartial(partial);\n },\n});\n\nconst createOrUpdatePartial = KnockTool({\n method: \"upsert_partial\",\n name: \"Upsert partial\",\n description: `\n Create or update a partial. A partial is a reusable piece of content that can be used in a template. Use this tool when you need to create a new partial or update an existing one.\n\n When working with a partial you must chose the type of the partial. The type determines the format of the content. If you're working with an email template, you should use the \"html\" or \"markdown\" type.\n\n If you need to work with dynamic content in your partial you can use liquid syntax. Liquid is a templating language that is supported in Knock. You can supply a variable like {{ some_variable }} in the content and it will be replaced with the actual value when the partial is used in a template.\n\n <example>\n {\n \"name\": \"Greeting\",\n \"key\": \"greeting\",\n \"type\": \"html\",\n \"content\": \"<div>Hello, {{ recipient_name }}</div>\"\n }\n </example>\n\n Changes to a partial MUST be committed before they can be used in a template.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to upsert the partial for. Defaults to `development`.\"\n ),\n key: z.string().describe(\"(string): The key of the partial to upsert.\"),\n name: z.string().describe(\"(string): The name of the partial.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the partial.\"),\n content: z.string().describe(\"(string): The content of the partial.\"),\n type: z\n .enum([\"html\", \"text\", \"json\", \"markdown\"])\n .describe(\"(string): The type of the partial.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const partial = await knockClient.partials.upsert(params.key, {\n environment: params.environment ?? config.environment ?? \"development\",\n partial: {\n name: params.name,\n description: params.description,\n content: params.content,\n type: params.type,\n },\n });\n return serializePartial(partial.partial);\n },\n});\n\nexport const partials = {\n getPartial,\n listPartials,\n createOrUpdatePartial,\n};\n\nexport const permissions = {\n read: [\"getPartial\", \"listPartials\"],\n manage: [\"createOrUpdatePartial\"],\n};\n","import { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getTenant = KnockTool({\n method: \"get_tenant\",\n name: \"Get tenant\",\n description: `\n Retrieves a tenant by their ID. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.\n \n Use this tool when you need to lookup the information about a tenant, including name, and if there are any custom properties set.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the tenant from. Defaults to `development`.\"\n ),\n tenantId: z\n .string()\n .describe(\"(string): The ID of the tenant to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.get(params.tenantId);\n },\n});\n\nconst listTenants = KnockTool({\n method: \"list_tenants\",\n name: \"List tenants\",\n description: `\n Retrieves a list of tenants. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object. \n \n Use this tool when you need to list all tenants in an environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the tenants from. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.list();\n },\n});\n\nconst createOrUpdateTenant = KnockTool({\n method: \"upsert_tenant\",\n name: \"Create or update tenant\",\n description: `\n Creates or updates a tenant using the properties provided. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.\n \n Use this tool when you need to create a new tenant, or update an existing tenant's properties.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to set the tenant in. Defaults to `development`.\"\n ),\n tenantId: z.string().describe(\"(string): The ID of the tenant to update.\"),\n name: z.string().optional().describe(\"(string): The name of the tenant.\"),\n properties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): The properties to set on the tenant.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.set(params.tenantId, {\n name: params.name,\n ...params.properties,\n });\n },\n});\n\nexport const tenants = {\n getTenant,\n listTenants,\n createOrUpdateTenant,\n};\n\nexport const permissions = {\n read: [\"getTenant\", \"listTenants\"],\n manage: [\"createOrUpdateTenant\"],\n};\n","import { User } from \"@knocklabs/node\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\nimport { serializeMessageResponse } from \"../utils.js\";\nfunction maybeHideUserData(user: User, hideUserData: boolean = false) {\n if (hideUserData) {\n return { id: user.id };\n }\n return user;\n}\n\nconst getUser = KnockTool({\n method: \"get_user\",\n name: \"Get user\",\n description: `\n Retrieves the complete user object for the given userId, including email, name, phone number, and any custom properties. Use this tool when you need to retrieve a user's complete profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to retrieve.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const user = await publicClient.users.get(params.userId ?? config.userId);\n\n return maybeHideUserData(user, config.hideUserData);\n },\n});\n\nconst createOrUpdateUser = KnockTool({\n method: \"upsert_user\",\n name: \"Create or update user\",\n description: `\n Creates a new user if they don't exist, or updates the user object for the given userId, including email, name, phone number, and any custom properties.\n \n Use this tool when you need to update a user's profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the user in. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to update.\"),\n email: z\n .string()\n .optional()\n .describe(\"(string): The email of the User to update.\"),\n name: z\n .string()\n .optional()\n .describe(\"(string): The name of the User to update.\"),\n phoneNumber: z\n .string()\n .optional()\n .describe(\"(string): The phone number of the User to update.\"),\n customProperties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): A dictionary of custom properties to update for the User.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const user = await publicClient.users.identify(\n params.userId ?? config.userId,\n {\n email: params.email,\n name: params.name,\n phone_number: params.phoneNumber,\n ...(params.customProperties ?? {}),\n }\n );\n\n return maybeHideUserData(user, config.hideUserData);\n },\n});\n\nconst getUserPreferences = KnockTool({\n method: \"get_user_preferences\",\n name: \"Get user preferences\",\n description: `\n Retrieves the user's notification preferences for the given userId.\n\n If the userId is not provided, it will use the userId from the config. \n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user preferences from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\n \"(string): The userId of the User to retrieve Preferences for.\"\n ),\n preferenceSetId: z\n .string()\n .optional()\n .describe(\n \"(string): The preferenceSetId of the User to retrieve preferences for. Defaults to `default`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: params.preferenceSetId ?? \"default\",\n }\n );\n },\n});\n\nconst setUserPreferences = KnockTool({\n method: \"set_user_preferences\",\n name: \"Set user preferences\",\n description: `\n Overwrites the user's notification preferences for the given userId. Allows setting per-workflow, per-category, or per-channel notification preferences. Use this tool when you are asked to update a user's notification preferences.\n\n If the userId is not provided, it will use the userId from the config.\n\n Instructions:\n\n - You must ALWAYS provide a full preference set to this tool.\n - When setting per-workflow preferences, the key in the object should be the workflow key.\n - Workflow and category preferences should always have channel types underneath.\n - The channel types available to you are: email, sms, push, chat, and in_app_feed.\n - To turn OFF a preference, you must set it to false.\n - To turn ON a preference, you must set it to true.\n\n <examples>\n <example>\n <description>\n Update the user's preferences to turn off email notifications for the \"welcome\" workflow.\n </description>\n <input>\n {\n \"workflows\": {\n \"welcome\": {\n \"channel_types\": {\n \"email\": false\n }\n }\n }\n }\n </example>\n </examples>\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to set the user preferences in. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to update preferences for.\"),\n workflows: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The workflows to update where the key is the workflow key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n categories: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The categories to update where the key is the category key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n channel_types: z\n .record(z.string(), z.boolean())\n .optional()\n .describe(\n \"(object): The channel types to update where the key is the channel type, and the value of the object is a boolean value.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const existingPreferences = await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: \"default\",\n }\n );\n\n const updatedPreferences = {\n ...existingPreferences,\n workflows: {\n ...existingPreferences.workflows,\n ...params.workflows,\n },\n categories: {\n ...existingPreferences.categories,\n ...params.categories,\n },\n channel_types: {\n ...existingPreferences.channel_types,\n ...params.channel_types,\n },\n };\n\n return await publicClient.users.setPreferences(\n params.userId ?? config.userId,\n updatedPreferences\n );\n },\n});\n\nconst getUserMessages = KnockTool({\n method: \"get_user_messages\",\n name: \"Get user messages\",\n description: `\n Retrieves the messages that this user has received from the service. Use this tool when you need information about the notifications that the user has received, including if the message has been read, seen, or interacted with. This will return a list of messages across all of the channels.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user messages from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to retrieve messages for.\"),\n workflowRunId: z\n .string()\n .optional()\n .describe(\n \"(string): The workflowRunId of the User to retrieve. Use this when you want to retrieve messages sent from a workflow trigger.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const messages = await publicClient.users.getMessages(\n params.userId ?? config.userId,\n {\n workflow_run_id: params.workflowRunId,\n }\n );\n\n return messages.items.map(serializeMessageResponse);\n },\n});\n\nexport const users = {\n getUser,\n createOrUpdateUser,\n getUserPreferences,\n setUserPreferences,\n getUserMessages,\n};\n\nexport const permissions = {\n read: [\"getUser\", \"getUserMessages\", \"getUserPreferences\"],\n manage: [\"createOrUpdateUser\", \"setUserPreferences\"],\n};\n","import { Workflow } from \"@knocklabs/mgmt/resources/index.mjs\";\nimport jsonSchemaToZod from \"json-schema-to-zod\";\nimport { z } from \"zod\";\n\nimport { Config } from \"../../types.js\";\nimport { KnockClient } from \"../knock-client.js\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nimport { recipientSchema } from \"./shared.js\";\n\n/**\n * Converts a workflow into a tool that can be used to trigger the workflow.\n *\n * @param workflow - The workflow to convert to a tool.\n *\n * @returns A `KnockTool` that can be used to trigger the workflow.\n */\nfunction workflowAsTool(workflow: Workflow) {\n return KnockTool({\n method: `trigger_${workflow.key.replace(\"-\", \"_\")}_workflow`,\n name: `Trigger ${workflow.name} workflow`,\n description: `Triggers the ${workflow.name} workflow. Use this tool when you're asked to notify, send, or trigger for ${workflow.name} or ${workflow.key}.\n\n ${workflow.description ? `Additional information to consider on when to use this tool: ${workflow.description}` : \"\"}\n \n Returns the workflow run ID, which can be used to lookup messages produced by the workflow.`,\n parameters: z.object({\n environment: z.string().optional(),\n actor: recipientSchema\n .optional()\n .describe(\"An optional actor to trigger the workflow with.\"),\n recipients: z\n .array(recipientSchema)\n .describe(\n \"An optional array of recipients to trigger the workflow with.\"\n )\n .optional(),\n // Here we dynamically generate a zod schema from the workflow's `trigger_data_json_schema`\n // This allows us to validate the data passed to the workflow\n data: workflow.trigger_data_json_schema\n ? eval(jsonSchemaToZod(workflow.trigger_data_json_schema)).describe(\n \"The data to pass to the workflow.\"\n )\n : z\n .record(z.string(), z.any())\n .optional()\n .describe(\"The data to pass to the workflow.\"),\n tenant: z\n .string()\n .optional()\n .describe(\"The tenant ID to trigger the workflow for.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const result = await publicClient.workflows.trigger(workflow.key, {\n recipients: params.recipients ?? [config.userId],\n actor: params.actor,\n data: params.data,\n tenant: params.tenant ?? config.tenantId,\n });\n\n return result.workflow_run_id;\n },\n });\n}\n\n/**\n * Creates a tool for each workflow in the given environment.\n *\n * @param knockClient - The Knock client to use to list workflows.\n * @param config - The config to use to list workflows.\n *\n * @returns An array of `KnockTool`s that can be used to trigger the workflows.\n */\nasync function createWorkflowTools(\n knockClient: KnockClient,\n config: Config,\n workflowKeysToInclude?: string[]\n) {\n const workflows: Workflow[] = [];\n\n for await (const workflow of knockClient.workflows.list({\n environment: config.environment ?? \"development\",\n })) {\n // If we have a list of workflow keys to include, and the current workflow is not in the list, skip it\n if (\n workflowKeysToInclude &&\n !workflowKeysToInclude.includes(workflow.key)\n ) {\n continue;\n }\n\n workflows.push(workflow);\n }\n\n // Build a tool for each workflow\n return workflows.map((workflow) => workflowAsTool(workflow));\n}\n\nexport { createWorkflowTools, workflowAsTool };\n","import { toolPermissions, tools } from \"../lib/tools/index.js\";\nimport { ToolkitConfig, ToolCategory } from \"../types.js\";\n\nimport { KnockClient } from \"./knock-client.js\";\nimport { KnockTool } from \"./knock-tool.js\";\nimport { createWorkflowTools } from \"./tools/workflows-as-tools.js\";\n\n/**\n * Given a list of tools, and some config may describe the tools that should be provided to the LLM,\n * returns a filtered list of tools that match the config.\n *\n * Options:\n * `*` - All tools\n * `users.*` - All tools that start with `users.`\n * `users.getUser` - A specific tool\n *\n */\nexport function filterTools(\n tools: Record<string, Record<string, KnockTool>>,\n pattern: string | undefined\n): KnockTool[] {\n if (!pattern) {\n throw new Error(\"No pattern provided\");\n }\n\n // If the pattern is `*`, return all tools\n if (pattern === \"*\") {\n return Object.values(tools).flatMap((category) => Object.values(category));\n }\n\n const [category, tool] = pattern.split(\".\");\n\n // If the pattern is `*.*`, return all tools\n if (category === \"*\" && tool === \"*\") {\n return Object.values(tools).flatMap((category) => Object.values(category));\n }\n\n if (category && !tools[category]) {\n throw new Error(`Tool category ${category} not found`);\n }\n\n // If the pattern is `users.*`, return all tools that start with `users.`\n if (category && tool === \"*\") {\n return Object.values(tools[category]);\n }\n\n // If the pattern is `users.getUser`, return the `getUser` tool\n if (category && tool && !tools[category][tool]) {\n throw new Error(`Tool ${pattern} not found`);\n }\n\n return [tools[category][tool]];\n}\n\n/**\n * Given a category and a list of permissions, return a list of tools that the user has permission to use.\n *\n * @param category - The category to get tools for\n * @param categoryPermissions - The permissions to use\n * @returns A list of tools that the user has permission to use\n */\nexport function getToolsWithPermissions(\n category: keyof typeof toolPermissions,\n categoryPermissions: Record<string, boolean | string[] | undefined>\n) {\n // Return all of the tools for the category that have permission\n const toolsInCategory = tools[category] as Record<string, KnockTool>;\n const toolPermissionsInCategory = toolPermissions[category] as Record<\n string,\n string[]\n >;\n\n // Look over each permission type, like `read: true`\n // If it's `true`, then find all of the tools that have that permission\n return Object.entries(categoryPermissions).reduce(\n (acc: KnockTool[], [permissionType, hasPermission]) => {\n if (\n (Array.isArray(hasPermission) && hasPermission.length > 0) ||\n hasPermission === true\n ) {\n return acc.concat(\n toolPermissionsInCategory[permissionType].map(\n (toolName) => toolsInCategory[toolName]\n )\n );\n }\n return acc;\n },\n []\n );\n}\n\n/**\n * Given a config, return a list of tools for each category that the user has permission to use.\n *\n * If the user has run permissions for workflows, then we need to get the workflow triggers tools,\n * and add them to the list of tools for the workflows category.\n *\n * @param config - The config to use\n * @returns A list of tools for each category that the user has permission to use\n */\nexport async function getToolsByPermissionsInCategories(\n knockClient: KnockClient,\n config: ToolkitConfig\n): Promise<Record<ToolCategory, KnockTool[]>> {\n const toolsByCategory = Object.keys(config.permissions).reduce(\n (acc, category) => {\n const categoryKey = category as ToolCategory;\n const categoryPermissions = config.permissions[categoryKey];\n\n if (tools[categoryKey] && categoryPermissions) {\n const tools = getToolsWithPermissions(categoryKey, categoryPermissions);\n\n return { ...acc, [categoryKey]: tools };\n }\n\n return acc;\n },\n {} as Record<ToolCategory, KnockTool[]>\n );\n\n // If the user has run permissions for workflows, then we need to get the workflow triggers tools,\n // and add them to the list of tools for the workflows category.\n if (\n config.permissions.workflows &&\n config.permissions.workflows.trigger &&\n Array.isArray(config.permissions.workflows.trigger)\n ) {\n const workflowTools = await createWorkflowTools(\n knockClient,\n config,\n config.permissions.workflows.trigger\n );\n toolsByCategory.workflows = [\n ...toolsByCategory.workflows,\n ...workflowTools,\n ];\n }\n\n return toolsByCategory;\n}\n\n/**\n * Given a list of tools, return a map of tools by method name.\n *\n * @param tools - The tools to serialize\n * @returns A map of tools by method name\n */\nexport function getToolMap(tools: KnockTool[]) {\n return tools.reduce(\n (acc, tool) => {\n acc[tool.method] = tool;\n return acc;\n },\n {} as Record<string, KnockTool>\n );\n}\n\n/**\n * Serialize a message response from the API to a more LLM-friendly format.\n *\n * @param message - The message to serialize\n * @returns A serialized message\n */\nexport function serializeMessageResponse(message: Record<string, any>) {\n return {\n id: message.id,\n status: message.status,\n engagement_statuses: message.engagement_statuses,\n data: message.data,\n metadata: message.metadata,\n };\n}\n","import { Workflow, WorkflowStep } from \"@knocklabs/mgmt/resources/index.js\";\nimport { z } from \"zod\";\n\nimport { KnockTool } from \"../knock-tool.js\";\n\nimport { workflowStepTools } from \"./workflow-steps.js\";\n\n/**\n * A slimmed down version of the Workflow resource that is easier to work with in the LLM.\n */\nexport type SerializedWorkflow = {\n key: string;\n name: string;\n description: string | undefined;\n categories: string[] | undefined;\n schema: Record<string, unknown> | undefined;\n};\n\nexport function serializeWorkflowResponse(\n workflow: Workflow\n): SerializedWorkflow {\n return {\n key: workflow.key,\n name: workflow.name,\n description: workflow.description,\n categories: workflow.categories,\n schema: workflow.trigger_data_json_schema,\n };\n}\n\nexport function serializeFullWorkflowResponse(\n workflow: Workflow\n): SerializedWorkflow & { steps: WorkflowStep[] } {\n return {\n key: workflow.key,\n name: workflow.name,\n description: workflow.description,\n categories: workflow.categories,\n schema: workflow.trigger_data_json_schema,\n steps: workflow.steps,\n };\n}\n\nconst listWorkflows = KnockTool({\n method: \"list_workflows\",\n name: \"List workflows\",\n description: `\n List all workflows available for the given environment. Returns structural information about the workflows, including the key, name, description, and categories.\n\n Use this tool when you need to understand which workflows are available to be called.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list workflows for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allWorkflows: SerializedWorkflow[] = [];\n const listParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n };\n\n for await (const workflow of knockClient.workflows.list(listParams)) {\n allWorkflows.push(serializeWorkflowResponse(workflow));\n }\n\n return allWorkflows;\n },\n});\n\nconst getWorkflow = KnockTool({\n method: \"get_workflow\",\n name: \"Get workflow\",\n description: `\n Get a workflow by key. Returns structural information about the workflow, including the key, name, description, and categories.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the workflow for. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: params.environment ?? config.environment ?? \"development\",\n });\n\n return serializeFullWorkflowResponse(workflow);\n },\n});\n\nconst triggerWorkflow = KnockTool({\n method: \"trigger_workflow\",\n name: \"Trigger workflow\",\n description: `\n Trigger a workflow for one or more recipients, which may produce one or more messages for each recipient depending on the workflow's steps.\n\n Use this tool when you need to trigger a workflow to send a notification across the channels configured for the workflow. \n\n When recipients aren't provided, the workflow will be triggered for the current user specified in the config.\n\n Returns the workflow run ID, which can be used to lookup messages produced by the workflow.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to trigger the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to trigger.\"),\n recipients: z\n .array(z.string())\n .optional()\n .describe(\n \"(array): The recipients to trigger the workflow for. This is an array of user IDs.\"\n ),\n data: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): Data to pass to the workflow.\"),\n tenant: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The tenant to trigger the workflow for. Must contain an id if being sent.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const result = await publicClient.workflows.trigger(params.workflowKey, {\n recipients: params.recipients ?? [config.userId] ?? [],\n data: params.data,\n tenant: params.tenant ?? config.tenantId,\n });\n\n return result.workflow_run_id;\n },\n});\n\nconst createWorkflow = KnockTool({\n method: \"create_workflow\",\n name: \"Create workflow\",\n description: `\n Create a new workflow, which is used to control the flow of notifications. Use this tool when you're asked to create a new workflow, or you need to create a new workflow before adding a step to it.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\n \"(string): The key of the workflow to create. Only use a kebab-case string with no spaces or special characters.\"\n ),\n name: z.string().describe(\"(string): The name of the workflow.\"),\n description: z\n .string()\n .describe(\"(string): The description of the workflow.\"),\n categories: z\n .array(z.string())\n .describe(\"(array): The categories to add to the workflow.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const result = await knockClient.workflows.upsert(params.workflowKey, {\n environment: config.environment ?? \"development\",\n workflow: {\n name: params.name,\n description: params.description,\n categories: params.categories ?? [],\n steps: [],\n },\n });\n\n return serializeWorkflowResponse(result.workflow);\n },\n});\n\nconst createOneOffWorkflowSchedule = KnockTool({\n method: \"create_one_off_workflow_schedule\",\n name: \"Create one-off workflow schedule\",\n description: `\n Create a one-off workflow schedule for a user. Use this tool when you need to schedule the execution of a workflow for a specific user in the future, like to power a delayed notification.\n \n Schedules can accept a set of data that will be passed to the workflow trigger when it is executed. When the userId is not provided, the schedule will be created for the current user specified in the config.\n\n Examples:\n \n - In three days, send a welcome email to a user\n - In one hour, send a password reset email to a user\n - In two weeks, send a survey to a user\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to schedule.\"),\n userId: z\n .string()\n .describe(\n \"(string): The userId of the user to schedule the workflow for.\"\n ),\n scheduledAt: z\n .string()\n .describe(\n \"(string): The date and time to schedule the workflow for. Must be in ISO 8601 format.\"\n ),\n data: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): Data to pass to the workflow.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.workflows.createSchedules(params.workflowKey, {\n recipients: [params.userId ?? config.userId],\n scheduled_at: params.scheduledAt,\n data: params.data,\n });\n },\n});\n\nexport const workflows = {\n listWorkflows,\n getWorkflow,\n triggerWorkflow,\n createWorkflow,\n ...workflowStepTools,\n createOneOffWorkflowSchedule,\n};\n\nexport const permissions = {\n read: [\"listWorkflows\", \"getWorkflow\"],\n manage: [\n \"createWorkflow\",\n \"createOneOffWorkflowSchedule\",\n \"triggerWorkflow\",\n ].concat(...Object.keys(workflowStepTools)),\n trigger: [],\n};\n","import {\n ChatTemplate,\n EmailTemplate,\n InAppFeedTemplate,\n PushTemplate,\n SMSTemplate,\n Workflow,\n WorkflowStep,\n WorkflowUpsertParams,\n} from \"@knocklabs/mgmt/resources/index.js\";\nimport { z } from \"zod\";\n\nimport { KnockClient } from \"../knock-client.js\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nimport { serializeWorkflowResponse } from \"./workflows\";\n\nfunction generateStepRef(stepType: string) {\n const randomString = Math.random().toString(36).substring(2, 7).toUpperCase();\n return `${stepType}_${randomString}`;\n}\n\nasync function updateWorkflowWithStep(\n knockClient: KnockClient,\n workflow: Workflow,\n step: WorkflowStep,\n environment: string\n) {\n let workflowSteps = workflow.steps;\n const existingStepIdx = workflow.steps.findIndex((s) => s.ref === step.ref);\n\n // If the step already exists, update it. Otherwise, add it to the end of the steps array.\n if (existingStepIdx !== -1) {\n workflowSteps[existingStepIdx] = step;\n } else {\n workflowSteps.push(step);\n }\n\n const workflowParams: WorkflowUpsertParams = {\n environment,\n workflow: {\n ...workflow,\n steps: workflowSteps,\n },\n };\n\n const result = await knockClient.workflows.upsert(\n workflow.key,\n workflowParams\n );\n\n return serializeWorkflowResponse(result.workflow);\n}\n\nconst SHARED_PROMPTS = {\n workflow: `\n To use this tool, you MUST first create a workflow using the \\`createWorkflow\\` tool, or get an existing workflow using the \\`getWorkflow\\` tool. \n \n If you are updating an existing step, you can pass the \\`stepRef\\` parameter to the tool. If you do not pass the \\`stepRef\\` parameter, a new step will be created and added to the end of the workflow's steps array. You should ONLY pass the \\`stepRef\\` parameter if you are updating an existing step.\n `,\n liquid: `\n ## Personalization\n\n If you need to include personalization, you can use liquid to include dynamic content in the email and the subject line.\n The following variables are always available to use in liquid:\n\n - \\`recipient.id\\`: The ID of the recipient.\n - \\`recipient.name\\`: The name of the recipient.\n - \\`recipient.email\\`: The email of the recipient.\n - \\`recipient.phone_number\\`: The phone number of the recipient.\n\n You can supply **any** other dynamic variables you think are needed by referencing them under the \\`data\\` key. You add those like \\`{{ data.variable_name }}\\`.\n\n <example>\n # Hello, {{ recipient.name }}\n\n This is a dynamic message:\n\n > {{ data.message }}\n </example>\n\n ## Liquid helpers\n\n You have access to a full suite of liquid helpers to help you perform common templating tasks. The full list of helper is available here: https://docs.knock.app/designing-workflows/template-editor/reference-liquid-helpers.\n\n <example>\n Hello, {{ recipient.name | split: \" \" | first | default: \"there\" }}\n </example>\n `,\n};\n\nconst contentBlockSchema = z.union([\n z.object({\n type: z.literal(\"markdown\"),\n content: z\n .string()\n .describe(\"(string): The markdown content of the block.\"),\n }),\n z.object({\n type: z.literal(\"html\"),\n content: z.string().describe(\"(string): The HTML content of the block.\"),\n }),\n z.object({\n type: z.literal(\"image\"),\n url: z.string().describe(\"(string): The URL of the image.\"),\n }),\n z.object({\n type: z.literal(\"button_set\"),\n buttons: z\n .array(\n z.object({\n label: z.string().describe(\"(string): The label of the button.\"),\n action: z.string().describe(\"(string): The action of the button.\"),\n variant: z\n .enum([\"solid\", \"outline\"])\n .default(\"solid\")\n .describe(\n \"(enum): The variant of the button. Defaults to `solid`.\"\n ),\n })\n )\n .describe(\"(array): The buttons for the button set.\"),\n }),\n z.object({\n type: z.literal(\"divider\"),\n }),\n z.object({\n type: z.literal(\"partial\"),\n key: z.string().describe(\"(string): The key of the partial to use.\"),\n name: z.string().describe(\"(string): The name of the partial.\"),\n attrs: z\n .record(z.string(), z.string())\n .describe(\n \"(object): The attributes for the partial. ALWAYS supply an empty object when you don't know which params are required.\"\n ),\n }),\n]);\n\nconst createOrUpdateEmailStepInWorkflow = KnockTool({\n method: \"upsert_workflow_email_step\",\n name: \"Create or update email step in workflow\",\n description: `\n Creates or updates an email step in a workflow. Use this tool when you're asked to create an email notification and you need to specify the content of the email.\n\n ${SHARED_PROMPTS.workflow}\n\n When you're asked to create an email step, you can either set the HTML content directly or use blocks to build the email. If you're asked to set the HTML content directly, you can use the \\`htmlContent\\` parameter. We prefer to use blocks.\n\n ## Blocks\n\n The content of the email is supplied as an array of \"blocks\". The simplest block is a \"markdown\" block, which supports content in a markdown format. That should always be your default block type.\n\n The following block types are supported:\n\n - \\`markdown\\`: A block that supports markdown content.\n - \\`html\\`: A block that supports markdown content.\n - \\`image\\`: A block that supports an image.\n - \\`button_set\\`: A block that adds one or more buttons.\n - \\`divider\\`: A block that supports a divider.\n - \\`partial\\`: A block that supports rendering a shared content partial.\n\n <example>\n {\n \"blocks\": [\n {\n \"type\": \"markdown\",\n \"content\": \"# Greetings from Knock!\\nHello, {{ recipient.name }}.\"\n },\n {\n \"type\": \"divider\"\n },\n {\n \"type\": \"button_set\",\n \"buttons\": [\n {\n \"label\": \"Approve\",\n \"action\": \"{{ data.primary_action_url }}\",\n \"variant\": \"solid\"\n }\n ]\n }\n ]\n }\n </example>\n\n ### Markdown\n\n When using the \\`markdown\\` block, you must supply a \\`content\\` key. The \\`content\\` key supports markdown.\n\n <example>\n {\n \"type\": \"markdown\",\n \"content\": \"Hello, world!\"\n }\n </example>\n\n ### HTML\n\n The \\`html\\` block supports raw HTML content. This should be used sparingly, and only when you need to include custom HTML content that markdown doesn't support. When using the \\`html\\` block, you must supply a \\`content\\` key. HTML content can include liquid personalization.\n\n ### Button sets\n\n Button sets are a special type of block that allows you to add one or more buttons to the email. They're useful for directing users to take specific actions. Button sets support one or more buttons. You must always include at least one button in a button set.\n\n Buttons are specified in a button set under the \\`buttons\\` key. Each button requires a \\`label\\`, \\`action\\`, and \\`variant\\`. The ONLY valid variants are \\`solid\\` and \\`outline\\`. The label and action can allowed be dynamic variables using liquid.\n\n <example>\n {\n \"type\": \"button_set\",\n \"buttons\": [\n {\n \"label\": \"Approve\",\n \"action\": \"https://example.com\",\n \"variant\": \"solid\"\n }\n ]\n }\n </example>\n\n ### Image\n\n Images are a special type of block that allows you to add an image to the email. When using the \\`image\\` block, you must supply a \\`url\\` key. The \\`url\\` key supports a URL to an image.\n\n <example>\n {\n \"type\": \"image\",\n \"url\": \"https://example.com/image.png\"\n }\n </example>\n\n ${SHARED_PROMPTS.liquid}\n\n ## Partials\n\n If you need to reuse content across multiple emails, you can create or reference an existing partial and reference it in the email. You should only use partials if you're instructed to do so.\n\n When you do need to use a partial in an email, you can use the \\`partial\\` block and then set the \\`key\\` to the key of the partial you want to use. If the partial requires any variables, you pass those in the \\`attrs\\` key.\n\n ## Writing style\n\n Unless asked otherwise, you should write content for the email in a concise and formal writing style. Do NOT use complex language or try to over explain. Keep the subject line to 8 words or less.\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n htmlContent: z\n .string()\n .optional()\n .describe(\n \"(string): The HTML content of the email template. Use this when not setting blocks.\"\n ),\n blocks: z\n .array(contentBlockSchema)\n .optional()\n .describe(\n \"(array): The blocks for the email step. Use this when you don't need to set HTML directly.\"\n ),\n layoutKey: z\n .string()\n .describe(\"(string): The key of the layout to use for the email step.\"),\n subject: z.string().describe(\"(string): The subject of the email step.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const emailChannelsPage = await knockClient.channels.list();\n const emailChannels = emailChannelsPage.entries.filter(\n (channel) => channel.type === \"email\"\n );\n\n if (emailChannels.length === 0) {\n throw new Error(\"No email channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: emailChannels[0].key,\n template: {\n settings: {\n layout_key: params.layoutKey ?? \"default\",\n },\n subject: params.subject,\n visual_blocks: params.blocks,\n html_content: params.htmlContent,\n } as EmailTemplate,\n ref: params.stepRef ?? generateStepRef(\"email\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst createOrUpdateSmsStepInWorkflow = KnockTool({\n method: \"upsert_workflow_sms_step\",\n name: \"Create or update sms step in workflow\",\n description: `\n Creates an SMS step in a workflow. Use this tool when you're asked to create an SMS notification and you need to specify the content of the SMS.\n\n ${SHARED_PROMPTS.workflow}\n\n ${SHARED_PROMPTS.liquid}\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n content: z.string().describe(\"(string): The content of the SMS.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const smsChannelsPage = await knockClient.channels.list();\n const smsChannels = smsChannelsPage.entries.filter(\n (channel) => channel.type === \"sms\"\n );\n\n if (smsChannels.length === 0) {\n throw new Error(\"No SMS channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: smsChannels[0].key,\n template: {\n text_body: params.content,\n } as SMSTemplate,\n ref: params.stepRef ?? generateStepRef(\"sms\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst createOrUpdatePushStepInWorkflow = KnockTool({\n method: \"upsert_workflow_push_step\",\n name: \"Create or update push step in workflow\",\n description: `\n Creates a push step in a workflow. Use this tool when you're asked to create a push notification and you need to specify the content of the push notification.\n\n ${SHARED_PROMPTS.workflow}\n\n ${SHARED_PROMPTS.liquid}\n\n Be terse in your writing as this is a push notification and should be direct and to the point.\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n title: z.string().describe(\"(string): The title of the push notification.\"),\n content: z\n .string()\n .describe(\"(string): The content (body) of the push notification.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const pushChannelsPage = await knockClient.channels.list();\n const pushChannels = pushChannelsPage.entries.filter(\n (channel) => channel.type === \"push\"\n );\n\n if (pushChannels.length === 0) {\n throw new Error(\"No push channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: pushChannels[0].key,\n template: {\n title: params.title,\n text_body: params.content,\n } as PushTemplate,\n ref: params.stepRef ?? generateStepRef(\"push\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\n// TODO: Add support for action buttons, not just the action URL\nconst createOrUpdateInAppFeedStepInWorkflow = KnockTool({\n method: \"upsert_workflow_in_app_step\",\n name: \"Create or update in app feed step in workflow\",\n description: `\n Creates an in app feed step in a workflow. Use this tool when you're asked to create an in app feed notification and you need to specify the content of the in app feed notification.\n\n ${SHARED_PROMPTS.workflow}\n\n ${SHARED_PROMPTS.liquid}\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n actionUrl: z\n .string()\n .describe(\n \"(string): The URL to navigate to when the in app feed is tapped.\"\n ),\n body: z\n .string()\n .describe(\"(string): The markdown content of the in app feed.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const inAppChannelsPage = await knockClient.channels.list();\n const inAppChannels = inAppChannelsPage.entries.filter(\n (channel) => channel.type === \"in_app_feed\"\n );\n\n if (inAppChannels.length === 0) {\n throw new Error(\"No in app channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: inAppChannels[0].key,\n template: {\n action_url: params.actionUrl,\n markdown_body: params.body,\n } as InAppFeedTemplate,\n ref: params.stepRef ?? generateStepRef(\"in_app_feed\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst createOrUpdateChatStepInWorkflow = KnockTool({\n method: \"upsert_workflow_chat_step\",\n name: \"Create or update chat step in workflow\",\n description: `\n Creates a chat step in a workflow. Use this tool when you're asked to create a chat, Slack, Discord, or Microsoft Teams notification and you need to specify the content of the chat notification.\n\n ${SHARED_PROMPTS.workflow}\n\n ${SHARED_PROMPTS.liquid}\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n body: z\n .string()\n .describe(\"(string): The markdown content of the notification.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const chatChannelsPage = await knockClient.channels.list();\n const chatChannels = chatChannelsPage.entries.filter(\n (channel) => channel.type === \"chat\"\n );\n\n if (chatChannels.length === 0) {\n throw new Error(\"No chat channels found\");\n }\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"channel\",\n channel_key: chatChannels[0].key,\n template: {\n markdown_body: params.body,\n } as ChatTemplate,\n ref: params.stepRef ?? generateStepRef(\"chat\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst createOrUpdateDelayStepInWorkflow = KnockTool({\n method: \"upsert_workflow_delay_step\",\n name: \"Create or update delay step in workflow\",\n description: `\n Creates a delay step in a workflow. Use this tool when you're asked to add a delay to the workflow that pauses, or waits for a period of time before continuing.\n\n ${SHARED_PROMPTS.workflow}\n\n Delays are specified in \"unit\" and \"value\" pairs. The only valid units are \"seconds\", \"minutes\", \"hours\", and \"days\".\n\n <example>\n {\n \"delayValue\": 5,\n \"delayUnit\": \"minutes\"\n }\n </example>\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n delayValue: z.number().describe(\"(number): The value of the delay.\"),\n delayUnit: z\n .enum([\"seconds\", \"minutes\", \"hours\", \"days\"])\n .describe(\"(enum): The unit of the delay.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n const workflowParams: WorkflowUpsertParams = {\n environment: config.environment ?? \"development\",\n workflow: {\n ...workflow,\n steps: [\n // @ts-expect-error\n ...workflow.steps,\n // @ts-expect-error\n {\n type: \"delay\",\n settings: {\n delay_for: {\n value: params.delayValue,\n unit: params.delayUnit,\n },\n },\n ref: params.stepRef ?? generateStepRef(\"delay\"),\n },\n ],\n },\n };\n\n const result = await knockClient.workflows.upsert(\n params.workflowKey,\n workflowParams\n );\n\n return serializeWorkflowResponse(result.workflow);\n },\n});\n\nconst createOrUpdateBatchStepInWorkflow = KnockTool({\n method: \"upsert_workflow_batch_step\",\n name: \"Create or update batch step in workflow\",\n description: `\n Creates a batch step in a workflow. Use this tool when you're asked to create a batch step or asked to add digesting behavior to a workflow. The batch step collects multiple workflow triggers for a single recipient over a period of time and then flushes the content to the next step.\n\n ${SHARED_PROMPTS.workflow}\n\n Batch windows are specified in \"unit\" and \"value\" pairs. The only valid units are \"seconds\", \"minutes\", \"hours\", and \"days\".\n\n <example>\n {\n \"batchWindow\": {\n \"value\": 5,\n \"unit\": \"minutes\"\n }\n }\n </example>\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to add the step to.\"),\n stepRef: z\n .string()\n .optional()\n .describe(\n \"(string): The reference of the step to update. If not provided, a new step will be created.\"\n ),\n batchWindow: z.object({\n value: z.number().describe(\"(number): The value of the batch window.\"),\n unit: z\n .enum([\"seconds\", \"minutes\", \"hours\", \"days\"])\n .describe(\"(enum): The unit of the batch window.\"),\n }),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: config.environment ?? \"development\",\n });\n\n return await updateWorkflowWithStep(\n knockClient,\n workflow,\n // @ts-expect-error\n {\n type: \"batch\",\n settings: {\n batch_window: {\n value: params.batchWindow.value,\n unit: params.batchWindow.unit,\n },\n },\n ref: params.stepRef ?? generateStepRef(\"batch\"),\n },\n config.environment ?? \"development\"\n );\n },\n});\n\nconst workflowStepTools = {\n // Channel steps\n createOrUpdateEmailStepInWorkflow,\n createOrUpdateSmsStepInWorkflow,\n createOrUpdatePushStepInWorkflow,\n createOrUpdateInAppFeedStepInWorkflow,\n createOrUpdateChatStepInWorkflow,\n\n // Function steps\n createOrUpdateDelayStepInWorkflow,\n createOrUpdateBatchStepInWorkflow,\n};\n\nexport { workflowStepTools };\n","import { channels, permissions as channelsPermissions } from \"./channels.js\";\nimport { commits, permissions as commitsPermissions } from \"./commits.js\";\nimport {\n documentation,\n permissions as documentationPermissions,\n} from \"./documentation.js\";\nimport {\n emailLayouts,\n permissions as emailLayoutsPermissions,\n} from \"./email-layouts.js\";\nimport {\n environments,\n permissions as environmentsPermissions,\n} from \"./environments.js\";\nimport { guides, permissions as guidesPermissions } from \"./guides.js\";\nimport {\n messageTypes,\n permissions as messageTypesPermissions,\n} from \"./message-types.js\";\nimport { messages, permissions as messagesPermissions } from \"./messages.js\";\nimport { objects, permissions as objectsPermissions } from \"./objects.js\";\nimport { partials, permissions as partialsPermissions } from \"./partials.js\";\nimport { tenants, permissions as tenantsPermissions } from \"./tenants.js\";\nimport { users, permissions as usersPermissions } from \"./users.js\";\nimport { workflows, permissions as workflowsPermissions } from \"./workflows.js\";\n\nexport const tools = {\n channels,\n commits,\n documentation,\n emailLayouts,\n environments,\n guides,\n messages,\n messageTypes,\n objects,\n partials,\n tenants,\n users,\n workflows,\n};\n\nexport const allTools = {\n ...channels,\n ...commits,\n ...documentation,\n ...emailLayouts,\n ...environments,\n ...guides,\n ...messageTypes,\n ...messages,\n ...objects,\n ...partials,\n ...tenants,\n ...users,\n ...workflows,\n};\n\nexport const toolPermissions = {\n channels: channelsPermissions,\n commits: commitsPermissions,\n documentation: documentationPermissions,\n emailLayouts: emailLayoutsPermissions,\n environments: environmentsPermissions,\n guides: guidesPermissions,\n messages: messagesPermissions,\n messageTypes: messageTypesPermissions,\n objects: objectsPermissions,\n partials: partialsPermissions,\n tenants: tenantsPermissions,\n users: usersPermissions,\n workflows: workflowsPermissions,\n};\n"],"mappings":";AACA,SAAS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F,EAAE,OAAO,GAAG,OAAO,KAAK,iBAAiB,CAAC;AAAA,EAC1C,SAAS,CAAC;AACZ;;;AEzOO,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,WAAW;AAAA,EACtB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEO,IAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,EACV,SAASC;AAAA,EACT,eAAeA;AAAA,EACf,cAAcA;AAAA,EACd,cAAcA;AAAA,EACd,QAAQA;AAAA,EACR,UAAUA;AAAA,EACV,cAAcA;AAAA,EACd,SAASA;AAAA,EACT,UAAUA;AAAA,EACV,SAASA;AAAA,EACT,OAAOA;AAAA,EACP,WAAWA;AACb;","names":["z","z","permissions","z","z","permissions","z","z","permissions","permissions","z","z","z","permissions","z","z","permissions","z","z","permissions","z","z","permissions","z","z","permissions","z","z","permissions","z","z","z","workflows","workflow","tools","category","z","messages","permissions","z","z","workflow","z","workflow","z","permissions","permissions"]}