@knocklabs/agent-toolkit 0.1.2 → 0.1.4

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 (74) hide show
  1. package/dist/ai-sdk/index.d.ts +1 -4
  2. package/dist/ai-sdk/index.js +7 -1076
  3. package/dist/ai-sdk/index.js.map +1 -1
  4. package/dist/{modelcontextprotocol/adapter.js → chunk-B6DIDKFY.js} +15 -2
  5. package/dist/chunk-B6DIDKFY.js.map +1 -0
  6. package/dist/{lib/tools/index.js → chunk-RPKDXX4O.js} +4 -3
  7. package/dist/{lib/utils.js.map → chunk-RPKDXX4O.js.map} +1 -1
  8. package/dist/chunk-ZV2SOIO7.js +91 -0
  9. package/dist/chunk-ZV2SOIO7.js.map +1 -0
  10. package/dist/modelcontextprotocol/index.d.ts +47 -6
  11. package/dist/modelcontextprotocol/index.js +4 -976
  12. package/dist/modelcontextprotocol/index.js.map +1 -1
  13. package/dist/modelcontextprotocol/local-server.js +10 -1041
  14. package/dist/modelcontextprotocol/local-server.js.map +1 -1
  15. package/dist/openai/index.d.ts +1 -4
  16. package/dist/openai/index.js +7 -1076
  17. package/dist/openai/index.js.map +1 -1
  18. package/dist/types-DyB12-Gk.d.ts +73 -0
  19. package/package.json +4 -4
  20. package/dist/ai-sdk/tool-converter.d.ts +0 -12
  21. package/dist/ai-sdk/tool-converter.js +0 -14
  22. package/dist/ai-sdk/tool-converter.js.map +0 -1
  23. package/dist/lib/knock-client.d.ts +0 -4
  24. package/dist/lib/knock-client.js +0 -28
  25. package/dist/lib/knock-client.js.map +0 -1
  26. package/dist/lib/knock-tool.d.ts +0 -4
  27. package/dist/lib/knock-tool.js +0 -29
  28. package/dist/lib/knock-tool.js.map +0 -1
  29. package/dist/lib/tools/channels.d.ts +0 -13
  30. package/dist/lib/tools/channels.js +0 -54
  31. package/dist/lib/tools/channels.js.map +0 -1
  32. package/dist/lib/tools/commits.d.ts +0 -16
  33. package/dist/lib/tools/commits.js +0 -98
  34. package/dist/lib/tools/commits.js.map +0 -1
  35. package/dist/lib/tools/email-layouts.d.ts +0 -13
  36. package/dist/lib/tools/email-layouts.js +0 -60
  37. package/dist/lib/tools/email-layouts.js.map +0 -1
  38. package/dist/lib/tools/environments.d.ts +0 -13
  39. package/dist/lib/tools/environments.js +0 -52
  40. package/dist/lib/tools/environments.js.map +0 -1
  41. package/dist/lib/tools/index.d.ts +0 -4
  42. package/dist/lib/tools/index.js.map +0 -1
  43. package/dist/lib/tools/message-types.d.ts +0 -15
  44. package/dist/lib/tools/message-types.js +0 -214
  45. package/dist/lib/tools/message-types.js.map +0 -1
  46. package/dist/lib/tools/messages.d.ts +0 -13
  47. package/dist/lib/tools/messages.js +0 -55
  48. package/dist/lib/tools/messages.js.map +0 -1
  49. package/dist/lib/tools/objects.d.ts +0 -19
  50. package/dist/lib/tools/objects.js +0 -163
  51. package/dist/lib/tools/objects.js.map +0 -1
  52. package/dist/lib/tools/partials.d.ts +0 -13
  53. package/dist/lib/tools/partials.js +0 -60
  54. package/dist/lib/tools/partials.js.map +0 -1
  55. package/dist/lib/tools/tenants.d.ts +0 -16
  56. package/dist/lib/tools/tenants.js +0 -98
  57. package/dist/lib/tools/tenants.js.map +0 -1
  58. package/dist/lib/tools/users.d.ts +0 -19
  59. package/dist/lib/tools/users.js +0 -233
  60. package/dist/lib/tools/users.js.map +0 -1
  61. package/dist/lib/tools/workflows.d.ts +0 -18
  62. package/dist/lib/tools/workflows.js +0 -207
  63. package/dist/lib/tools/workflows.js.map +0 -1
  64. package/dist/lib/utils.d.ts +0 -33
  65. package/dist/lib/utils.js +0 -1077
  66. package/dist/modelcontextprotocol/adapter.d.ts +0 -11
  67. package/dist/modelcontextprotocol/adapter.js.map +0 -1
  68. package/dist/openai/tool-converter.d.ts +0 -15
  69. package/dist/openai/tool-converter.js +0 -18
  70. package/dist/openai/tool-converter.js.map +0 -1
  71. package/dist/types-B-9pppCQ.d.ts +0 -199
  72. package/dist/types.d.ts +0 -4
  73. package/dist/types.js +0 -1
  74. package/dist/types.js.map +0 -1
@@ -1,55 +0,0 @@
1
- // src/lib/tools/messages.ts
2
- import { z as z2 } from "zod";
3
-
4
- // src/lib/knock-tool.ts
5
- import { z } from "zod";
6
- var trimLines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
7
- var KnockTool = (args) => {
8
- const { execute, ...restOfArgs } = args;
9
- const parameters = restOfArgs.parameters ? restOfArgs.parameters : z.object({});
10
- const schemaEntries = Object.entries(parameters.shape);
11
- const argsStr = schemaEntries.length === 0 ? "Takes no arguments" : schemaEntries.map(([key, value]) => {
12
- return `- ${key}: ${value.description || ""}`;
13
- }).join("\n");
14
- const fullDescription = trimLines(`
15
- Tool name:
16
- ${args.name}
17
- Description:
18
- ${args.description}.
19
- Arguments:
20
- ${argsStr}
21
- `);
22
- return {
23
- ...restOfArgs,
24
- parameters,
25
- fullDescription,
26
- bindExecute: (knockClient, config) => execute(knockClient, config)
27
- };
28
- };
29
-
30
- // src/lib/tools/messages.ts
31
- var getMessageContent = KnockTool({
32
- method: "get_message_content",
33
- name: "Get message content",
34
- description: `
35
- 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.
36
- `,
37
- parameters: z2.object({
38
- messageId: z2.string().describe("(string): The messageId of the message to retrieve.")
39
- }),
40
- execute: (knockClient) => async (params) => {
41
- const publicClient = await knockClient.publicApi();
42
- return await publicClient.messages.getContent(params.messageId);
43
- }
44
- });
45
- var messages = {
46
- getMessageContent
47
- };
48
- var permissions = {
49
- read: ["getMessageContent"]
50
- };
51
- export {
52
- messages,
53
- permissions
54
- };
55
- //# sourceMappingURL=messages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/tools/messages.ts","../../../src/lib/knock-tool.ts"],"sourcesContent":["import { z } from \"zod\";\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 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();\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 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":";AAAA,SAAS,KAAAA,UAAS;;;ACClB,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;;;ADtFA,IAAM,oBAAoB,UAAU;AAAA,EAClC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAYC,GAAE,OAAO;AAAA,IACnB,WAAWA,GACR,OAAO,EACP,SAAS,qDAAqD;AAAA,EACnE,CAAC;AAAA,EACD,SAAS,CAAC,gBAAgB,OAAO,WAAW;AAC1C,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,WAAO,MAAM,aAAa,SAAS,WAAW,OAAO,SAAS;AAAA,EAChE;AACF,CAAC;AAEM,IAAM,WAAW;AAAA,EACtB;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,mBAAmB;AAC5B;","names":["z","z"]}
@@ -1,19 +0,0 @@
1
- import { a as KnockTool } from '../../types-B-9pppCQ.js';
2
- import 'zod';
3
- import '@knocklabs/node';
4
- import '@knocklabs/mgmt';
5
-
6
- declare const objects: {
7
- listObjects: KnockTool;
8
- getObject: KnockTool;
9
- createOrUpdateObject: KnockTool;
10
- deleteObject: KnockTool;
11
- subscribeUsersToObject: KnockTool;
12
- unsubscribeUsersFromObject: KnockTool;
13
- };
14
- declare const permissions: {
15
- read: string[];
16
- manage: string[];
17
- };
18
-
19
- export { objects, permissions };
@@ -1,163 +0,0 @@
1
- // src/lib/tools/objects.ts
2
- import { z as z2 } from "zod";
3
-
4
- // src/lib/knock-tool.ts
5
- import { z } from "zod";
6
- var trimLines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
7
- var KnockTool = (args) => {
8
- const { execute, ...restOfArgs } = args;
9
- const parameters = restOfArgs.parameters ? restOfArgs.parameters : z.object({});
10
- const schemaEntries = Object.entries(parameters.shape);
11
- const argsStr = schemaEntries.length === 0 ? "Takes no arguments" : schemaEntries.map(([key, value]) => {
12
- return `- ${key}: ${value.description || ""}`;
13
- }).join("\n");
14
- const fullDescription = trimLines(`
15
- Tool name:
16
- ${args.name}
17
- Description:
18
- ${args.description}.
19
- Arguments:
20
- ${argsStr}
21
- `);
22
- return {
23
- ...restOfArgs,
24
- parameters,
25
- fullDescription,
26
- bindExecute: (knockClient, config) => execute(knockClient, config)
27
- };
28
- };
29
-
30
- // src/lib/tools/objects.ts
31
- var listObjects = KnockTool({
32
- method: "list_objects",
33
- name: "List objects",
34
- 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.",
35
- parameters: z2.object({
36
- collection: z2.string().describe("(string): The collection to list objects from.")
37
- }),
38
- execute: (knockClient, config) => async (params) => {
39
- const publicClient = await knockClient.publicApi();
40
- return await publicClient.objects.list(params.collection);
41
- }
42
- });
43
- var getObject = KnockTool({
44
- method: "get_object",
45
- name: "Get object",
46
- 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.",
47
- parameters: z2.object({
48
- collection: z2.string().describe("(string): The collection to get the object from."),
49
- objectId: z2.string().describe("(string): The ID of the object to get.")
50
- }),
51
- execute: (knockClient, config) => async (params) => {
52
- const publicClient = await knockClient.publicApi();
53
- return await publicClient.objects.get(params.collection, params.objectId);
54
- }
55
- });
56
- var createOrUpdateObject = KnockTool({
57
- method: "create_or_update_object",
58
- name: "Create or update object",
59
- 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.
60
-
61
- 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.`,
62
- parameters: z2.object({
63
- collection: z2.string().describe("(string): The collection to create or update the object in."),
64
- objectId: z2.string().describe("(string): The ID of the object to create or update."),
65
- properties: z2.record(z2.string(), z2.any()).describe("(object): The properties to set on the object.")
66
- }),
67
- execute: (knockClient, config) => async (params) => {
68
- const publicClient = await knockClient.publicApi();
69
- return await publicClient.objects.set(
70
- params.collection,
71
- params.objectId,
72
- params.properties
73
- );
74
- }
75
- });
76
- var deleteObject = KnockTool({
77
- method: "delete_object",
78
- name: "Delete object",
79
- description: `Delete an object from a specific collection. Use this tool when you need to remove an object from the system.`,
80
- parameters: z2.object({
81
- collection: z2.string().describe("(string): The collection to delete the object from."),
82
- objectId: z2.string().describe("(string): The ID of the object to delete.")
83
- }),
84
- execute: (knockClient, config) => async (params) => {
85
- const publicClient = await knockClient.publicApi();
86
- await publicClient.objects.delete(params.collection, params.objectId);
87
- return { success: true };
88
- }
89
- });
90
- var subscribeUsersToObject = KnockTool({
91
- method: "subscribe_users_to_object",
92
- name: "Subscribe users to object",
93
- description: `
94
- 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.
95
-
96
- 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.
97
-
98
- Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.
99
- `,
100
- parameters: z2.object({
101
- collection: z2.string().describe("(string): The collection to subscribe the user to."),
102
- objectId: z2.string().describe("(string): The ID of the object to subscribe the user to."),
103
- userIds: z2.array(z2.string()).describe(
104
- "(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed."
105
- )
106
- }),
107
- execute: (knockClient, config) => async (params) => {
108
- const publicClient = await knockClient.publicApi();
109
- return await publicClient.objects.addSubscriptions(
110
- params.collection,
111
- params.objectId,
112
- {
113
- recipients: params.userIds ?? [config.userId]
114
- }
115
- );
116
- }
117
- });
118
- var unsubscribeUsersFromObject = KnockTool({
119
- method: "unsubscribe_users_from_object",
120
- name: "Unsubscribe users from object",
121
- 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.
122
-
123
- 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.`,
124
- parameters: z2.object({
125
- collection: z2.string().describe("(string): The collection to unsubscribe the user from."),
126
- objectId: z2.string().describe("(string): The ID of the object to unsubscribe the user from."),
127
- userIds: z2.array(z2.string()).describe(
128
- "(array): The IDs of the users to unsubscribe from the object."
129
- )
130
- }),
131
- execute: (knockClient, config) => async (params) => {
132
- const publicClient = await knockClient.publicApi();
133
- return await publicClient.objects.deleteSubscriptions(
134
- params.collection,
135
- params.objectId,
136
- {
137
- recipients: params.userIds ?? [config.userId]
138
- }
139
- );
140
- }
141
- });
142
- var objects = {
143
- listObjects,
144
- getObject,
145
- createOrUpdateObject,
146
- deleteObject,
147
- subscribeUsersToObject,
148
- unsubscribeUsersFromObject
149
- };
150
- var permissions = {
151
- read: ["listObjects", "getObject"],
152
- manage: [
153
- "createOrUpdateObject",
154
- "deleteObject",
155
- "subscribeUsersToObject",
156
- "unsubscribeUsersFromObject"
157
- ]
158
- };
159
- export {
160
- objects,
161
- permissions
162
- };
163
- //# sourceMappingURL=objects.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/tools/objects.ts","../../../src/lib/knock-tool.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","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":";AAAA,SAAS,KAAAA,UAAS;;;ACClB,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/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AUA,GACP,OAAO,EACP,SAAS,8DAA8D;AAAA,IAC1E,SAASA,GACN,MAAMA,GAAE,OAAO,CAAC,EAChB;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,WAAO,MAAM,aAAa,QAAQ;AAAA,MAChC,OAAO;AAAA,MACP,OAAO;AAAA,MACP;AAAA,QACE,YAAY,OAAO,WAAW,CAAC,OAAO,MAAM;AAAA,MAC9C;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAEM,IAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,eAAe,WAAW;AAAA,EACjC,QAAQ;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["z","z"]}
@@ -1,13 +0,0 @@
1
- import { a as KnockTool } from '../../types-B-9pppCQ.js';
2
- import 'zod';
3
- import '@knocklabs/node';
4
- import '@knocklabs/mgmt';
5
-
6
- declare const partials: {
7
- listPartials: KnockTool;
8
- };
9
- declare const permissions: {
10
- read: string[];
11
- };
12
-
13
- export { partials, permissions };
@@ -1,60 +0,0 @@
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
- // src/lib/tools/partials.ts
28
- import { z as z2 } from "zod";
29
- var listPartials = KnockTool({
30
- method: "list_partials",
31
- name: "List partials",
32
- description: `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.
33
-
34
- 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.`,
35
- parameters: z2.object({
36
- environment: z2.string().describe(
37
- "(string): The environment to list partials for. Defaults to `development`."
38
- )
39
- }),
40
- execute: (knockClient, config) => async (params) => {
41
- const allPartials = [];
42
- for await (const partial of knockClient.partials.list({
43
- environment: params.environment ?? config.environment ?? "development"
44
- })) {
45
- allPartials.push(partial);
46
- }
47
- return allPartials;
48
- }
49
- });
50
- var partials = {
51
- listPartials
52
- };
53
- var permissions = {
54
- read: ["listPartials"]
55
- };
56
- export {
57
- partials,
58
- permissions
59
- };
60
- //# sourceMappingURL=partials.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/knock-tool.ts","../../../src/lib/tools/partials.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","import { KnockTool } from \"../knock-tool.js\";\nimport { z } from \"zod\";\nimport { Partial } from \"@knocklabs/mgmt/resources/partials.js\";\n\nconst listPartials = KnockTool({\n method: \"list_partials\",\n name: \"List partials\",\n description: `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 \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 .describe(\n \"(string): The environment to list partials for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allPartials: Partial[] = [];\n for await (const partial of knockClient.partials.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allPartials.push(partial);\n }\n return allPartials;\n },\n});\n\nexport const partials = {\n listPartials,\n};\n\nexport const permissions = {\n read: [\"listPartials\"],\n};\n"],"mappings":";AACA,SAAS,SAAS;AA8ClB,IAAM,YAAY,CAAC,SACjB,KACG,MAA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c;AACvB;","names":["z"]}
@@ -1,16 +0,0 @@
1
- import { a as KnockTool } from '../../types-B-9pppCQ.js';
2
- import 'zod';
3
- import '@knocklabs/node';
4
- import '@knocklabs/mgmt';
5
-
6
- declare const tenants: {
7
- getTenant: KnockTool;
8
- setTenant: KnockTool;
9
- deleteTenant: KnockTool;
10
- };
11
- declare const permissions: {
12
- read: string[];
13
- manage: string[];
14
- };
15
-
16
- export { permissions, tenants };
@@ -1,98 +0,0 @@
1
- // src/lib/tools/tenants.ts
2
- import { z as z2 } from "zod";
3
-
4
- // src/lib/knock-tool.ts
5
- import { z } from "zod";
6
- var trimLines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
7
- var KnockTool = (args) => {
8
- const { execute, ...restOfArgs } = args;
9
- const parameters = restOfArgs.parameters ? restOfArgs.parameters : z.object({});
10
- const schemaEntries = Object.entries(parameters.shape);
11
- const argsStr = schemaEntries.length === 0 ? "Takes no arguments" : schemaEntries.map(([key, value]) => {
12
- return `- ${key}: ${value.description || ""}`;
13
- }).join("\n");
14
- const fullDescription = trimLines(`
15
- Tool name:
16
- ${args.name}
17
- Description:
18
- ${args.description}.
19
- Arguments:
20
- ${argsStr}
21
- `);
22
- return {
23
- ...restOfArgs,
24
- parameters,
25
- fullDescription,
26
- bindExecute: (knockClient, config) => execute(knockClient, config)
27
- };
28
- };
29
-
30
- // src/lib/tools/tenants.ts
31
- var getTenant = KnockTool({
32
- method: "get_tenant",
33
- name: "Get tenant",
34
- description: `
35
- 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.
36
-
37
- Use this tool when you need to lookup the information about a tenant, including name, and if there are any custom properties set.
38
- `,
39
- parameters: z2.object({
40
- tenantId: z2.string().describe("(string): The ID of the tenant to retrieve.")
41
- }),
42
- execute: (knockClient) => async (params) => {
43
- const publicClient = await knockClient.publicApi();
44
- return await publicClient.tenants.get(params.tenantId);
45
- }
46
- });
47
- var setTenant = KnockTool({
48
- method: "set_tenant",
49
- name: "Set tenant",
50
- description: `
51
- 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.
52
-
53
- Use this tool when you need to create a new tenant, or update an existing tenant's properties.
54
- `,
55
- parameters: z2.object({
56
- tenantId: z2.string().describe("(string): The ID of the tenant to update."),
57
- name: z2.string().describe("(string): The name of the tenant."),
58
- properties: z2.record(z2.string(), z2.any()).describe("(object): The properties to set on the tenant.")
59
- }),
60
- execute: (knockClient) => async (params) => {
61
- const publicClient = await knockClient.publicApi();
62
- return await publicClient.tenants.set(params.tenantId, {
63
- name: params.name,
64
- ...params.properties
65
- });
66
- }
67
- });
68
- var deleteTenant = KnockTool({
69
- method: "delete_tenant",
70
- name: "Delete tenant",
71
- description: `
72
- Deletes a tenant. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.
73
-
74
- Use this tool when you've been asked to remove a tenant from the system.
75
- `,
76
- parameters: z2.object({
77
- tenantId: z2.string().describe("(string): The ID of the tenant to delete.")
78
- }),
79
- execute: (knockClient) => async (params) => {
80
- const publicClient = await knockClient.publicApi();
81
- await publicClient.tenants.delete(params.tenantId);
82
- return { success: true };
83
- }
84
- });
85
- var tenants = {
86
- getTenant,
87
- setTenant,
88
- deleteTenant
89
- };
90
- var permissions = {
91
- read: ["getTenant"],
92
- manage: ["setTenant", "deleteTenant"]
93
- };
94
- export {
95
- permissions,
96
- tenants
97
- };
98
- //# sourceMappingURL=tenants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/tools/tenants.ts","../../../src/lib/knock-tool.ts"],"sourcesContent":["import { z } from \"zod\";\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 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();\n return await publicClient.tenants.get(params.tenantId);\n },\n});\n\nconst setTenant = KnockTool({\n method: \"set_tenant\",\n name: \"Set 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 tenantId: z.string().describe(\"(string): The ID of the tenant to update.\"),\n name: z.string().describe(\"(string): The name of the tenant.\"),\n properties: z\n .record(z.string(), z.any())\n .describe(\"(object): The properties to set on the tenant.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.tenants.set(params.tenantId, {\n name: params.name,\n ...params.properties,\n });\n },\n});\n\nconst deleteTenant = KnockTool({\n method: \"delete_tenant\",\n name: \"Delete tenant\",\n description: `\n Deletes a tenant. 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've been asked to remove a tenant from the system.\n `,\n parameters: z.object({\n tenantId: z.string().describe(\"(string): The ID of the tenant to delete.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi();\n await publicClient.tenants.delete(params.tenantId);\n return { success: true };\n },\n});\n\nexport const tenants = {\n getTenant,\n setTenant,\n deleteTenant,\n};\n\nexport const permissions = {\n read: [\"getTenant\"],\n manage: [\"setTenant\", \"deleteTenant\"],\n};\n","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":";AAAA,SAAS,KAAAA,UAAS;;;ACClB,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,W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D,MAAM,OAAO;AAAA,MACb,GAAG,OAAO;AAAA,IACZ,CAAC;AAAA,EACH;AACF,CAAC;AAED,IAAM,eAAe,UAAU;AAAA,EAC7B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAYA,GAAE,OAAO;AAAA,IACnB,UAAUA,GAAE,OAAO,EAAE,SAAS,2CAA2C;AAAA,EAC3E,CAAC;AAAA,EACD,SAAS,CAAC,gBAAgB,OAAO,WAAW;AAC1C,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,UAAM,aAAa,QAAQ,OAAO,OAAO,QAAQ;AACjD,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACF,CAAC;AAEM,IAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,WAAW;AAAA,EAClB,QAAQ,CAAC,aAAa,cAAc;AACtC;","names":["z","z"]}
@@ -1,19 +0,0 @@
1
- import { a as KnockTool } from '../../types-B-9pppCQ.js';
2
- import 'zod';
3
- import '@knocklabs/node';
4
- import '@knocklabs/mgmt';
5
-
6
- declare const users: {
7
- getUser: KnockTool;
8
- deleteUser: KnockTool;
9
- createOrUpdateUser: KnockTool;
10
- getUserPreferences: KnockTool;
11
- setUserPreferences: KnockTool;
12
- getUserMessages: KnockTool;
13
- };
14
- declare const permissions: {
15
- read: string[];
16
- manage: string[];
17
- };
18
-
19
- export { permissions, users };