@knocklabs/agent-toolkit 0.1.1 → 0.1.3

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.
Files changed (109) hide show
  1. package/dist/ai-sdk/index.d.ts +21 -0
  2. package/dist/ai-sdk/index.js +47 -0
  3. package/dist/ai-sdk/index.js.map +1 -0
  4. package/dist/ai-sdk/tool-converter.d.ts +12 -0
  5. package/dist/ai-sdk/tool-converter.js +7 -0
  6. package/dist/ai-sdk/tool-converter.js.map +1 -0
  7. package/dist/chunk-2CNJ4XX6.js +33 -0
  8. package/dist/chunk-2CNJ4XX6.js.map +1 -0
  9. package/dist/chunk-3LZK6RH6.js +29 -0
  10. package/dist/chunk-3LZK6RH6.js.map +1 -0
  11. package/dist/chunk-4VR65G5W.js +66 -0
  12. package/dist/chunk-4VR65G5W.js.map +1 -0
  13. package/dist/chunk-6H3BXH2Y.js +15 -0
  14. package/dist/chunk-6H3BXH2Y.js.map +1 -0
  15. package/dist/chunk-BY4KQPUO.js +39 -0
  16. package/dist/chunk-BY4KQPUO.js.map +1 -0
  17. package/dist/chunk-DSRTYV37.js +39 -0
  18. package/dist/chunk-DSRTYV37.js.map +1 -0
  19. package/dist/chunk-JTYQTWCX.js +75 -0
  20. package/dist/chunk-JTYQTWCX.js.map +1 -0
  21. package/dist/chunk-NZB2TMJW.js +92 -0
  22. package/dist/chunk-NZB2TMJW.js.map +1 -0
  23. package/dist/chunk-O6DWF42E.js +31 -0
  24. package/dist/chunk-O6DWF42E.js.map +1 -0
  25. package/dist/chunk-OD5VHBGN.js +32 -0
  26. package/dist/chunk-OD5VHBGN.js.map +1 -0
  27. package/dist/chunk-PDMA6RIB.js +19 -0
  28. package/dist/chunk-PDMA6RIB.js.map +1 -0
  29. package/dist/chunk-RYMJEH6P.js +140 -0
  30. package/dist/chunk-RYMJEH6P.js.map +1 -0
  31. package/dist/chunk-THLK376Y.js +191 -0
  32. package/dist/chunk-THLK376Y.js.map +1 -0
  33. package/dist/chunk-TLHETJRF.js +75 -0
  34. package/dist/chunk-TLHETJRF.js.map +1 -0
  35. package/dist/chunk-TOBLV65T.js +30 -0
  36. package/dist/chunk-TOBLV65T.js.map +1 -0
  37. package/dist/chunk-VJFA3ZVW.js +210 -0
  38. package/dist/chunk-VJFA3ZVW.js.map +1 -0
  39. package/dist/chunk-WB4XCCUS.js +19 -0
  40. package/dist/chunk-WB4XCCUS.js.map +1 -0
  41. package/dist/chunk-XRQWR3LY.js +184 -0
  42. package/dist/chunk-XRQWR3LY.js.map +1 -0
  43. package/dist/chunk-XUYE3AGB.js +27 -0
  44. package/dist/chunk-XUYE3AGB.js.map +1 -0
  45. package/dist/lib/knock-client.d.ts +4 -0
  46. package/dist/lib/knock-client.js +7 -0
  47. package/dist/lib/knock-client.js.map +1 -0
  48. package/dist/lib/knock-tool.d.ts +4 -0
  49. package/dist/lib/knock-tool.js +7 -0
  50. package/dist/lib/knock-tool.js.map +1 -0
  51. package/dist/lib/tools/channels.d.ts +13 -0
  52. package/dist/lib/tools/channels.js +10 -0
  53. package/dist/lib/tools/channels.js.map +1 -0
  54. package/dist/lib/tools/commits.d.ts +16 -0
  55. package/dist/lib/tools/commits.js +10 -0
  56. package/dist/lib/tools/commits.js.map +1 -0
  57. package/dist/lib/tools/email-layouts.d.ts +13 -0
  58. package/dist/lib/tools/email-layouts.js +10 -0
  59. package/dist/lib/tools/email-layouts.js.map +1 -0
  60. package/dist/lib/tools/environments.d.ts +13 -0
  61. package/dist/lib/tools/environments.js +10 -0
  62. package/dist/lib/tools/environments.js.map +1 -0
  63. package/dist/lib/tools/index.d.ts +4 -0
  64. package/dist/lib/tools/index.js +23 -0
  65. package/dist/lib/tools/index.js.map +1 -0
  66. package/dist/lib/tools/message-types.d.ts +15 -0
  67. package/dist/lib/tools/message-types.js +10 -0
  68. package/dist/lib/tools/message-types.js.map +1 -0
  69. package/dist/lib/tools/messages.d.ts +13 -0
  70. package/dist/lib/tools/messages.js +10 -0
  71. package/dist/lib/tools/messages.js.map +1 -0
  72. package/dist/lib/tools/objects.d.ts +19 -0
  73. package/dist/lib/tools/objects.js +10 -0
  74. package/dist/lib/tools/objects.js.map +1 -0
  75. package/dist/lib/tools/partials.d.ts +13 -0
  76. package/dist/lib/tools/partials.js +10 -0
  77. package/dist/lib/tools/partials.js.map +1 -0
  78. package/dist/lib/tools/tenants.d.ts +16 -0
  79. package/dist/lib/tools/tenants.js +10 -0
  80. package/dist/lib/tools/tenants.js.map +1 -0
  81. package/dist/lib/tools/users.d.ts +19 -0
  82. package/dist/lib/tools/users.js +10 -0
  83. package/dist/lib/tools/users.js.map +1 -0
  84. package/dist/lib/tools/workflows.d.ts +18 -0
  85. package/dist/lib/tools/workflows.js +10 -0
  86. package/dist/lib/tools/workflows.js.map +1 -0
  87. package/dist/lib/utils.d.ts +33 -0
  88. package/dist/lib/utils.js +24 -0
  89. package/dist/lib/utils.js.map +1 -0
  90. package/dist/modelcontextprotocol/adapter.d.ts +11 -0
  91. package/dist/modelcontextprotocol/adapter.js +7 -0
  92. package/dist/modelcontextprotocol/adapter.js.map +1 -0
  93. package/dist/modelcontextprotocol/index.d.ts +27 -0
  94. package/dist/modelcontextprotocol/index.js +21 -0
  95. package/dist/modelcontextprotocol/index.js.map +1 -0
  96. package/dist/modelcontextprotocol/local-server.d.ts +1 -0
  97. package/dist/modelcontextprotocol/local-server.js +86 -0
  98. package/dist/modelcontextprotocol/local-server.js.map +1 -0
  99. package/dist/openai/index.d.ts +36 -0
  100. package/dist/openai/index.js +86 -0
  101. package/dist/openai/index.js.map +1 -0
  102. package/dist/openai/tool-converter.d.ts +15 -0
  103. package/dist/openai/tool-converter.js +7 -0
  104. package/dist/openai/tool-converter.js.map +1 -0
  105. package/dist/types-B-9pppCQ.d.ts +199 -0
  106. package/dist/types.d.ts +4 -0
  107. package/dist/types.js +1 -0
  108. package/dist/types.js.map +1 -0
  109. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/modelcontextprotocol/index.ts"],"sourcesContent":["import type { KnockTool } from \"../lib/knock-tool.js\";\nimport { allTools } from \"../lib/tools/index.js\";\nimport { KnockMcpServer } from \"./adapter.js\";\nimport { Config } from \"../types.js\";\nimport { KnockClient } from \"../lib/knock-client.js\";\n\ntype CreateKnockMcpServerParams = {\n /**\n * Array of Knock tools to enable in the server.\n */\n tools?: KnockTool[];\n\n /**\n * A Knock client to use for the server.\n */\n knockClient: KnockClient;\n\n /**\n * The config to use for the server.\n */\n config: Config;\n};\n\n/**\n * Creates a Knock MCP Server with the given parameters.\n */\nexport const createKnockMcpServer = async (\n params: CreateKnockMcpServerParams\n): Promise<KnockMcpServer> => {\n const { tools, knockClient, config } = params;\n\n return Promise.resolve(\n new KnockMcpServer(knockClient, config, tools || Object.values(allTools))\n );\n};\n"],"mappings":";;;;;;;;AA0BO,IAAM,uBAAuB,OAClC,WAC4B;AAC5B,QAAM,EAAE,OAAO,aAAa,OAAO,IAAI;AAEvC,SAAO,QAAQ;AAAA,IACb,IAAI,eAAe,aAAa,QAAQ,SAAS,OAAO,OAAO,QAAQ,CAAC;AAAA,EAC1E;AACF;","names":[]}
@@ -0,0 +1,140 @@
1
+ import {
2
+ KnockTool
3
+ } from "./chunk-TOBLV65T.js";
4
+
5
+ // src/lib/tools/objects.ts
6
+ import { z } from "zod";
7
+ var listObjects = KnockTool({
8
+ method: "list_objects",
9
+ name: "List objects",
10
+ description: "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.",
11
+ parameters: z.object({
12
+ collection: z.string().describe("(string): The collection to list objects from.")
13
+ }),
14
+ execute: (knockClient, config) => async (params) => {
15
+ const publicClient = await knockClient.publicApi();
16
+ return await publicClient.objects.list(params.collection);
17
+ }
18
+ });
19
+ var getObject = KnockTool({
20
+ method: "get_object",
21
+ name: "Get object",
22
+ description: "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.",
23
+ parameters: z.object({
24
+ collection: z.string().describe("(string): The collection to get the object from."),
25
+ objectId: z.string().describe("(string): The ID of the object to get.")
26
+ }),
27
+ execute: (knockClient, config) => async (params) => {
28
+ const publicClient = await knockClient.publicApi();
29
+ return await publicClient.objects.get(params.collection, params.objectId);
30
+ }
31
+ });
32
+ var createOrUpdateObject = KnockTool({
33
+ method: "create_or_update_object",
34
+ name: "Create or update object",
35
+ 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.
36
+
37
+ 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.`,
38
+ parameters: z.object({
39
+ collection: z.string().describe("(string): The collection to create or update the object in."),
40
+ objectId: z.string().describe("(string): The ID of the object to create or update."),
41
+ properties: z.record(z.string(), z.any()).describe("(object): The properties to set on the object.")
42
+ }),
43
+ execute: (knockClient, config) => async (params) => {
44
+ const publicClient = await knockClient.publicApi();
45
+ return await publicClient.objects.set(
46
+ params.collection,
47
+ params.objectId,
48
+ params.properties
49
+ );
50
+ }
51
+ });
52
+ var deleteObject = KnockTool({
53
+ method: "delete_object",
54
+ name: "Delete object",
55
+ description: `Delete an object from a specific collection. Use this tool when you need to remove an object from the system.`,
56
+ parameters: z.object({
57
+ collection: z.string().describe("(string): The collection to delete the object from."),
58
+ objectId: z.string().describe("(string): The ID of the object to delete.")
59
+ }),
60
+ execute: (knockClient, config) => async (params) => {
61
+ const publicClient = await knockClient.publicApi();
62
+ await publicClient.objects.delete(params.collection, params.objectId);
63
+ return { success: true };
64
+ }
65
+ });
66
+ var subscribeUsersToObject = KnockTool({
67
+ method: "subscribe_users_to_object",
68
+ name: "Subscribe users to object",
69
+ description: `
70
+ 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.
71
+
72
+ 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.
73
+
74
+ Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.
75
+ `,
76
+ parameters: z.object({
77
+ collection: z.string().describe("(string): The collection to subscribe the user to."),
78
+ objectId: z.string().describe("(string): The ID of the object to subscribe the user to."),
79
+ userIds: z.array(z.string()).describe(
80
+ "(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed."
81
+ )
82
+ }),
83
+ execute: (knockClient, config) => async (params) => {
84
+ const publicClient = await knockClient.publicApi();
85
+ return await publicClient.objects.addSubscriptions(
86
+ params.collection,
87
+ params.objectId,
88
+ {
89
+ recipients: params.userIds ?? [config.userId]
90
+ }
91
+ );
92
+ }
93
+ });
94
+ var unsubscribeUsersFromObject = KnockTool({
95
+ method: "unsubscribe_users_from_object",
96
+ name: "Unsubscribe users from object",
97
+ 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.
98
+
99
+ 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.`,
100
+ parameters: z.object({
101
+ collection: z.string().describe("(string): The collection to unsubscribe the user from."),
102
+ objectId: z.string().describe("(string): The ID of the object to unsubscribe the user from."),
103
+ userIds: z.array(z.string()).describe(
104
+ "(array): The IDs of the users to unsubscribe from the object."
105
+ )
106
+ }),
107
+ execute: (knockClient, config) => async (params) => {
108
+ const publicClient = await knockClient.publicApi();
109
+ return await publicClient.objects.deleteSubscriptions(
110
+ params.collection,
111
+ params.objectId,
112
+ {
113
+ recipients: params.userIds ?? [config.userId]
114
+ }
115
+ );
116
+ }
117
+ });
118
+ var objects = {
119
+ listObjects,
120
+ getObject,
121
+ createOrUpdateObject,
122
+ deleteObject,
123
+ subscribeUsersToObject,
124
+ unsubscribeUsersFromObject
125
+ };
126
+ var permissions = {
127
+ read: ["listObjects", "getObject"],
128
+ manage: [
129
+ "createOrUpdateObject",
130
+ "deleteObject",
131
+ "subscribeUsersToObject",
132
+ "unsubscribeUsersFromObject"
133
+ ]
134
+ };
135
+
136
+ export {
137
+ objects,
138
+ permissions
139
+ };
140
+ //# sourceMappingURL=chunk-RYMJEH6P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/objects.ts"],"sourcesContent":["import { z } from \"zod\";\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 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();\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 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();\n return await publicClient.objects.get(params.collection, params.objectId);\n },\n});\n\nconst createOrUpdateObject = KnockTool({\n method: \"create_or_update_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 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 .describe(\"(object): The properties to set on the object.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.set(\n params.collection,\n params.objectId,\n params.properties\n );\n },\n});\n\nconst deleteObject = KnockTool({\n method: \"delete_object\",\n name: \"Delete object\",\n description: `Delete an object from a specific collection. Use this tool when you need to remove an object from the system.`,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to delete the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to delete.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n await publicClient.objects.delete(params.collection, params.objectId);\n return { success: true };\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 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();\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 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();\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 deleteObject,\n subscribeUsersToObject,\n unsubscribeUsersFromObject,\n};\n\nexport const permissions = {\n read: [\"listObjects\", \"getObject\"],\n manage: [\n \"createOrUpdateObject\",\n \"deleteObject\",\n \"subscribeUsersToObject\",\n \"unsubscribeUsersFromObject\",\n ],\n};\n"],"mappings":"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","names":[]}
@@ -0,0 +1,191 @@
1
+ import {
2
+ KnockTool
3
+ } from "./chunk-TOBLV65T.js";
4
+
5
+ // src/lib/tools/message-types.ts
6
+ import { z } from "zod";
7
+ var listMessageTypes = KnockTool({
8
+ method: "list_message_types",
9
+ name: "List message types",
10
+ description: "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.",
11
+ parameters: z.object({
12
+ environment: z.string().describe(
13
+ "(string): The environment to list message types for. Defaults to `development`."
14
+ )
15
+ }),
16
+ execute: (knockClient, config) => async (params) => {
17
+ const allMessageTypes = [];
18
+ for await (const messageType of knockClient.messageTypes.list({
19
+ environment: params.environment ?? config.environment ?? "development"
20
+ })) {
21
+ allMessageTypes.push(messageType);
22
+ }
23
+ return allMessageTypes;
24
+ }
25
+ });
26
+ var createOrUpdateMessageType = KnockTool({
27
+ method: "create_or_update_message_type",
28
+ name: "Create or update message type",
29
+ description: `
30
+ 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".
31
+
32
+ Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.
33
+
34
+ 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 }}.
35
+
36
+ <example>
37
+ <description>
38
+ Create a new message type for a banner component that has a text and an action URL.
39
+ </description>
40
+ <input>
41
+ {
42
+ "messageTypeKey": "banner",
43
+ "name": "Banner",
44
+ "description": "A banner component that has a text and an action URL.",
45
+ "preview": "<div>{{ text }}</div>",
46
+ "variants": [
47
+ {
48
+ "key": "default",
49
+ "name": "Default",
50
+ "fields": [
51
+ {
52
+ "key": "text",
53
+ "type": "text",
54
+ "label": "Text",
55
+ "settings": {
56
+ "max_length": 100,
57
+ },
58
+ },
59
+ {
60
+ "key": "action_url",
61
+ "type": "text",
62
+ "label": "Action URL",
63
+ "settings": {
64
+ "placeholder": "https://example.com",
65
+ },
66
+ }
67
+ ]
68
+ }
69
+ ]
70
+ }
71
+ </input>
72
+ </example>
73
+ <example>
74
+ <description>
75
+ Create a message type for a card component that has an icon type, title, body, and a single action button.
76
+ </description>
77
+ <input>
78
+ {
79
+ "messageTypeKey": "card",
80
+ "name": "Card",
81
+ "description": "A single-action card component.",
82
+ "preview": "
83
+ <div>
84
+ <h2>{{ title }}</h2>
85
+ <p>{{ body }}</p>
86
+ <button>Action</button>
87
+ </div>
88
+ ",
89
+ "variants": [
90
+ {
91
+ "key": "default",
92
+ "name": "Default",
93
+ "fields": [
94
+ {
95
+ "key": "icon_type",
96
+ "type": "select",
97
+ "label": "Icon type",
98
+ "settings": {
99
+ "options": [
100
+ {
101
+ "value": "warning",
102
+ "label": "Warning",
103
+ },
104
+ {
105
+ "value": "success",
106
+ "label": "Success",
107
+ },
108
+ {
109
+ "value": "info",
110
+ "label": "Info",
111
+ },
112
+ {
113
+ "value": "error",
114
+ "label": "Error",
115
+ },
116
+ ]
117
+ },
118
+ },
119
+ {
120
+ "key": "title",
121
+ "type": "text",
122
+ "label": "Title",
123
+ },
124
+ {
125
+ "key": "description",
126
+ "type": "markdown",
127
+ "label": "Description",
128
+ },
129
+ {
130
+ "key": "action_button",
131
+ "type": "button",
132
+ "label": "Action button",
133
+ },
134
+ ]
135
+ }
136
+ ]
137
+ }
138
+ </input>
139
+ </example>
140
+ `,
141
+ parameters: z.object({
142
+ messageTypeKey: z.string().describe("(string): The key of the message type to create or update."),
143
+ name: z.string().describe("(string): The name of the message type."),
144
+ description: z.string().optional().describe("(string): The description of the message type."),
145
+ preview: z.string().optional().describe(
146
+ "(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."
147
+ ),
148
+ variants: z.array(
149
+ z.object({
150
+ key: z.string().describe("(string): The key of the variant."),
151
+ name: z.string().describe("(string): The name of the variant."),
152
+ description: z.string().optional().describe("(string): The description of the variant."),
153
+ fields: z.array(
154
+ z.object({
155
+ key: z.string().describe("(string): The key of the field."),
156
+ type: z.string().describe(
157
+ "(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`."
158
+ ),
159
+ label: z.string().describe("(string): The label of the field."),
160
+ settings: z.object({}).describe("(object): The settings of the field.")
161
+ })
162
+ ).describe("(array): The fields of the variant.")
163
+ })
164
+ ).describe("(array): The variants of the message type.")
165
+ }),
166
+ execute: (knockClient, config) => async (params) => {
167
+ return await knockClient.messageTypes.upsert(params.messageTypeKey, {
168
+ message_type: {
169
+ name: params.name,
170
+ variants: params.variants,
171
+ description: params.description ?? "",
172
+ preview: params.preview ?? "<div></div>"
173
+ },
174
+ environment: params.environment ?? config.environment ?? "development"
175
+ });
176
+ }
177
+ });
178
+ var messageTypes = {
179
+ listMessageTypes,
180
+ createOrUpdateMessageType
181
+ };
182
+ var permissions = {
183
+ read: ["listMessageTypes"],
184
+ manage: ["createOrUpdateMessageType"]
185
+ };
186
+
187
+ export {
188
+ messageTypes,
189
+ permissions
190
+ };
191
+ //# sourceMappingURL=chunk-THLK376Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/message-types.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { MessageType } from \"@knocklabs/mgmt/resources/message-types.js\";\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 .describe(\n \"(string): The environment to list message types for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allMessageTypes: MessageType[] = [];\n for await (const messageType of knockClient.messageTypes.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allMessageTypes.push(messageType);\n }\n return allMessageTypes;\n },\n});\n\nconst createOrUpdateMessageType = KnockTool({\n method: \"create_or_update_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\".\n \n Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.\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 }}.\n\n <example>\n <description>\n Create a new message type for a banner component that has a text and an action URL.\n </description>\n <input>\n {\n \"messageTypeKey\": \"banner\",\n \"name\": \"Banner\",\n \"description\": \"A banner component that has a text and an action URL.\",\n \"preview\": \"<div>{{ text }}</div>\",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"text\",\n \"type\": \"text\",\n \"label\": \"Text\",\n \"settings\": {\n \"max_length\": 100,\n },\n },\n {\n \"key\": \"action_url\",\n \"type\": \"text\",\n \"label\": \"Action URL\",\n \"settings\": {\n \"placeholder\": \"https://example.com\",\n },\n }\n ]\n }\n ]\n }\n </input>\n </example>\n <example>\n <description>\n Create a message type for a card component that has an icon type, title, body, and a single action button.\n </description>\n <input>\n {\n \"messageTypeKey\": \"card\",\n \"name\": \"Card\",\n \"description\": \"A single-action card component.\",\n \"preview\": \"\n <div>\n <h2>{{ title }}</h2>\n <p>{{ body }}</p>\n <button>Action</button>\n </div>\n \",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"icon_type\",\n \"type\": \"select\",\n \"label\": \"Icon type\",\n \"settings\": {\n \"options\": [\n {\n \"value\": \"warning\",\n \"label\": \"Warning\",\n },\n {\n \"value\": \"success\",\n \"label\": \"Success\",\n },\n {\n \"value\": \"info\",\n \"label\": \"Info\",\n },\n {\n \"value\": \"error\",\n \"label\": \"Error\",\n },\n ]\n },\n },\n {\n \"key\": \"title\",\n \"type\": \"text\",\n \"label\": \"Title\",\n },\n {\n \"key\": \"description\",\n \"type\": \"markdown\",\n \"label\": \"Description\",\n },\n {\n \"key\": \"action_button\",\n \"type\": \"button\",\n \"label\": \"Action button\",\n },\n ]\n }\n ]\n }\n </input>\n </example>\n `,\n parameters: z.object({\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`.\"\n ),\n label: z.string().describe(\"(string): The label of the field.\"),\n settings: z\n .object({})\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"],"mappings":"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","names":[]}
@@ -0,0 +1,75 @@
1
+ import {
2
+ KnockTool
3
+ } from "./chunk-TOBLV65T.js";
4
+
5
+ // src/lib/tools/commits.ts
6
+ import { z } from "zod";
7
+ var listCommits = KnockTool({
8
+ method: "list_commits",
9
+ name: "List commits",
10
+ description: `
11
+ Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.
12
+ `,
13
+ parameters: z.object({
14
+ environment: z.string().describe(
15
+ "(string): The environment to list commits for. Defaults to `development`."
16
+ ),
17
+ promoted: z.boolean().describe(
18
+ "(boolean): Whether to only return promoted commits. Defaults to `false`."
19
+ )
20
+ }),
21
+ execute: (knockClient, config) => async (params) => {
22
+ return await knockClient.commits.list({
23
+ environment: params.environment ?? config.environment ?? "development",
24
+ promoted: params.promoted ?? false
25
+ });
26
+ }
27
+ });
28
+ var commitAllChanges = KnockTool({
29
+ method: "commit_all_changes",
30
+ name: "Commit all changes",
31
+ description: `
32
+ Commit all pending changes to the current environment. Use this tool when you are asked to save all changes to the current environment. This can only be used in the development environment.
33
+ `,
34
+ parameters: z.object({
35
+ message: z.string().describe("(string): The message to include in the commit.")
36
+ }),
37
+ execute: (knockClient, config) => async (params) => {
38
+ return await knockClient.commits.commitAll({
39
+ environment: config.environment ?? "development",
40
+ commit_message: params.message
41
+ });
42
+ }
43
+ });
44
+ var promoteAllCommits = KnockTool({
45
+ method: "promote_all_commits",
46
+ name: "Promote all commits",
47
+ description: `
48
+ Promote all commits to the next environment. Use this tool when you are asked to deploy all changes.
49
+
50
+ When not specified, the \`toEnvironment\` will default to the environment that comes after the environment specified in the config.
51
+ `,
52
+ parameters: z.object({
53
+ toEnvironment: z.string().describe("(string): The environment to promote all commits to.")
54
+ }),
55
+ execute: (knockClient, config) => async (params) => {
56
+ return await knockClient.put("/v1/commits/promote", {
57
+ body: { to_environment: params.toEnvironment }
58
+ });
59
+ }
60
+ });
61
+ var commits = {
62
+ listCommits,
63
+ commitAllChanges,
64
+ promoteAllCommits
65
+ };
66
+ var permissions = {
67
+ read: ["listCommits"],
68
+ manage: ["commitAllChanges", "promoteAllCommits"]
69
+ };
70
+
71
+ export {
72
+ commits,
73
+ permissions
74
+ };
75
+ //# sourceMappingURL=chunk-TLHETJRF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/tools/commits.ts"],"sourcesContent":["import { z } from \"zod\";\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 .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 to the current environment. Use this tool when you are asked to save all changes to the current environment. This can only be used in the development environment.\n `,\n parameters: z.object({\n message: z\n .string()\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: 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 When not specified, the \\`toEnvironment\\` will default to the environment that comes after the environment specified in the config.\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"],"mappings":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,cAAc,UAAU;AAAA,EAC5B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,aAAa,EACV,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,IACF,UAAU,EACP,QAAQ,EACR;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,QAAQ,KAAK;AAAA,MACpC,aAAa,OAAO,eAAe,OAAO,eAAe;AAAA,MACzD,UAAU,OAAO,YAAY;AAAA,IAC/B,CAAC;AAAA,EACH;AACF,CAAC;AAED,IAAM,mBAAmB,UAAU;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,SAAS,EACN,OAAO,EACP,SAAS,iDAAiD;AAAA,EAC/D,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,QAAQ,UAAU;AAAA,MACzC,aAAa,OAAO,eAAe;AAAA,MACnC,gBAAgB,OAAO;AAAA,IACzB,CAAC;AAAA,EACH;AACF,CAAC;AAED,IAAM,oBAAoB,UAAU;AAAA,EAClC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAY,EAAE,OAAO;AAAA,IACnB,eAAe,EACZ,OAAO,EACP,SAAS,sDAAsD;AAAA,EACpE,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,IAAI,uBAAuB;AAAA,MAClD,MAAM,EAAE,gBAAgB,OAAO,cAAc;AAAA,IAC/C,CAAC;AAAA,EACH;AACF,CAAC;AAEM,IAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,aAAa;AAAA,EACpB,QAAQ,CAAC,oBAAoB,mBAAmB;AAClD;","names":[]}
@@ -0,0 +1,30 @@
1
+ // src/lib/knock-tool.ts
2
+ import { z } from "zod";
3
+ var trimLines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
4
+ var KnockTool = (args) => {
5
+ const { execute, ...restOfArgs } = args;
6
+ const parameters = restOfArgs.parameters ? restOfArgs.parameters : z.object({});
7
+ const schemaEntries = Object.entries(parameters.shape);
8
+ const argsStr = schemaEntries.length === 0 ? "Takes no arguments" : schemaEntries.map(([key, value]) => {
9
+ return `- ${key}: ${value.description || ""}`;
10
+ }).join("\n");
11
+ const fullDescription = trimLines(`
12
+ Tool name:
13
+ ${args.name}
14
+ Description:
15
+ ${args.description}.
16
+ Arguments:
17
+ ${argsStr}
18
+ `);
19
+ return {
20
+ ...restOfArgs,
21
+ parameters,
22
+ fullDescription,
23
+ bindExecute: (knockClient, config) => execute(knockClient, config)
24
+ };
25
+ };
26
+
27
+ export {
28
+ KnockTool
29
+ };
30
+ //# sourceMappingURL=chunk-TOBLV65T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/knock-tool.ts"],"sourcesContent":["import type { ZodObject } from \"zod\";\nimport { z } from \"zod\";\nimport { Config } from \"../types.js\";\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: (knockClient: KnockClient, config: Config) =>\n execute(knockClient, config),\n };\n};\n"],"mappings":";AACA,SAAS,SAAS;AA8ClB,IAAM,YAAY,CAAC,SACjB,KACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,KAAK,IAAI;AAEP,IAAM,YAAY,CACvB,SACc;AACd,QAAM,EAAE,SAAS,GAAG,WAAW,IAAI;AACnC,QAAM,aAAa,WAAW,aAC1B,WAAW,aACX,EAAE,OAAO,CAAC,CAAC;AAEf,QAAM,gBAAgB,OAAO,QAAQ,WAAW,KAAK;AAErD,QAAM,UACJ,cAAc,WAAW,IACrB,uBACA,cACG,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACrB,WAAO,KAAK,GAAG,KAAM,MAAc,eAAe,EAAE;AAAA,EACtD,CAAC,EACA,KAAK,IAAI;AAElB,QAAM,kBAAkB,UAAU;AAAA;AAAA,IAEhC,KAAK,IAAI;AAAA;AAAA,IAET,KAAK,WAAW;AAAA;AAAA,IAEhB,OAAO;AAAA,GACR;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA,aAAa,CAAC,aAA0B,WACtC,QAAQ,aAAa,MAAM;AAAA,EAC/B;AACF;","names":[]}