@knocklabs/agent-toolkit 0.1.3 → 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 (112) hide show
  1. package/dist/ai-sdk/index.d.ts +1 -4
  2. package/dist/ai-sdk/index.js +14 -20
  3. package/dist/ai-sdk/index.js.map +1 -1
  4. package/dist/{chunk-XUYE3AGB.js → chunk-B6DIDKFY.js} +14 -2
  5. package/dist/chunk-B6DIDKFY.js.map +1 -0
  6. package/dist/chunk-RPKDXX4O.js +1023 -0
  7. package/dist/chunk-RPKDXX4O.js.map +1 -0
  8. package/dist/{chunk-4VR65G5W.js → chunk-ZV2SOIO7.js} +29 -4
  9. package/dist/chunk-ZV2SOIO7.js.map +1 -0
  10. package/dist/modelcontextprotocol/index.d.ts +47 -6
  11. package/dist/modelcontextprotocol/index.js +2 -15
  12. package/dist/modelcontextprotocol/local-server.js +5 -20
  13. package/dist/modelcontextprotocol/local-server.js.map +1 -1
  14. package/dist/openai/index.d.ts +1 -4
  15. package/dist/openai/index.js +18 -20
  16. package/dist/openai/index.js.map +1 -1
  17. package/dist/types-DyB12-Gk.d.ts +73 -0
  18. package/package.json +2 -2
  19. package/dist/ai-sdk/tool-converter.d.ts +0 -12
  20. package/dist/ai-sdk/tool-converter.js +0 -7
  21. package/dist/ai-sdk/tool-converter.js.map +0 -1
  22. package/dist/chunk-2CNJ4XX6.js +0 -33
  23. package/dist/chunk-2CNJ4XX6.js.map +0 -1
  24. package/dist/chunk-3LZK6RH6.js +0 -29
  25. package/dist/chunk-3LZK6RH6.js.map +0 -1
  26. package/dist/chunk-4VR65G5W.js.map +0 -1
  27. package/dist/chunk-6H3BXH2Y.js +0 -15
  28. package/dist/chunk-6H3BXH2Y.js.map +0 -1
  29. package/dist/chunk-BY4KQPUO.js +0 -39
  30. package/dist/chunk-BY4KQPUO.js.map +0 -1
  31. package/dist/chunk-DSRTYV37.js +0 -39
  32. package/dist/chunk-DSRTYV37.js.map +0 -1
  33. package/dist/chunk-JTYQTWCX.js +0 -75
  34. package/dist/chunk-JTYQTWCX.js.map +0 -1
  35. package/dist/chunk-NZB2TMJW.js +0 -92
  36. package/dist/chunk-NZB2TMJW.js.map +0 -1
  37. package/dist/chunk-O6DWF42E.js +0 -31
  38. package/dist/chunk-O6DWF42E.js.map +0 -1
  39. package/dist/chunk-OD5VHBGN.js +0 -32
  40. package/dist/chunk-OD5VHBGN.js.map +0 -1
  41. package/dist/chunk-PDMA6RIB.js +0 -19
  42. package/dist/chunk-PDMA6RIB.js.map +0 -1
  43. package/dist/chunk-RYMJEH6P.js +0 -140
  44. package/dist/chunk-RYMJEH6P.js.map +0 -1
  45. package/dist/chunk-THLK376Y.js +0 -191
  46. package/dist/chunk-THLK376Y.js.map +0 -1
  47. package/dist/chunk-TLHETJRF.js +0 -75
  48. package/dist/chunk-TLHETJRF.js.map +0 -1
  49. package/dist/chunk-TOBLV65T.js +0 -30
  50. package/dist/chunk-TOBLV65T.js.map +0 -1
  51. package/dist/chunk-VJFA3ZVW.js +0 -210
  52. package/dist/chunk-VJFA3ZVW.js.map +0 -1
  53. package/dist/chunk-WB4XCCUS.js +0 -19
  54. package/dist/chunk-WB4XCCUS.js.map +0 -1
  55. package/dist/chunk-XRQWR3LY.js +0 -184
  56. package/dist/chunk-XRQWR3LY.js.map +0 -1
  57. package/dist/chunk-XUYE3AGB.js.map +0 -1
  58. package/dist/lib/knock-client.d.ts +0 -4
  59. package/dist/lib/knock-client.js +0 -7
  60. package/dist/lib/knock-client.js.map +0 -1
  61. package/dist/lib/knock-tool.d.ts +0 -4
  62. package/dist/lib/knock-tool.js +0 -7
  63. package/dist/lib/knock-tool.js.map +0 -1
  64. package/dist/lib/tools/channels.d.ts +0 -13
  65. package/dist/lib/tools/channels.js +0 -10
  66. package/dist/lib/tools/channels.js.map +0 -1
  67. package/dist/lib/tools/commits.d.ts +0 -16
  68. package/dist/lib/tools/commits.js +0 -10
  69. package/dist/lib/tools/commits.js.map +0 -1
  70. package/dist/lib/tools/email-layouts.d.ts +0 -13
  71. package/dist/lib/tools/email-layouts.js +0 -10
  72. package/dist/lib/tools/email-layouts.js.map +0 -1
  73. package/dist/lib/tools/environments.d.ts +0 -13
  74. package/dist/lib/tools/environments.js +0 -10
  75. package/dist/lib/tools/environments.js.map +0 -1
  76. package/dist/lib/tools/index.d.ts +0 -4
  77. package/dist/lib/tools/index.js +0 -23
  78. package/dist/lib/tools/index.js.map +0 -1
  79. package/dist/lib/tools/message-types.d.ts +0 -15
  80. package/dist/lib/tools/message-types.js +0 -10
  81. package/dist/lib/tools/message-types.js.map +0 -1
  82. package/dist/lib/tools/messages.d.ts +0 -13
  83. package/dist/lib/tools/messages.js +0 -10
  84. package/dist/lib/tools/messages.js.map +0 -1
  85. package/dist/lib/tools/objects.d.ts +0 -19
  86. package/dist/lib/tools/objects.js +0 -10
  87. package/dist/lib/tools/objects.js.map +0 -1
  88. package/dist/lib/tools/partials.d.ts +0 -13
  89. package/dist/lib/tools/partials.js +0 -10
  90. package/dist/lib/tools/partials.js.map +0 -1
  91. package/dist/lib/tools/tenants.d.ts +0 -16
  92. package/dist/lib/tools/tenants.js +0 -10
  93. package/dist/lib/tools/tenants.js.map +0 -1
  94. package/dist/lib/tools/users.d.ts +0 -19
  95. package/dist/lib/tools/users.js +0 -10
  96. package/dist/lib/tools/users.js.map +0 -1
  97. package/dist/lib/tools/workflows.d.ts +0 -18
  98. package/dist/lib/tools/workflows.js +0 -10
  99. package/dist/lib/tools/workflows.js.map +0 -1
  100. package/dist/lib/utils.d.ts +0 -33
  101. package/dist/lib/utils.js +0 -24
  102. package/dist/lib/utils.js.map +0 -1
  103. package/dist/modelcontextprotocol/adapter.d.ts +0 -11
  104. package/dist/modelcontextprotocol/adapter.js +0 -7
  105. package/dist/modelcontextprotocol/adapter.js.map +0 -1
  106. package/dist/openai/tool-converter.d.ts +0 -15
  107. package/dist/openai/tool-converter.js +0 -7
  108. package/dist/openai/tool-converter.js.map +0 -1
  109. package/dist/types-B-9pppCQ.d.ts +0 -199
  110. package/dist/types.d.ts +0 -4
  111. package/dist/types.js +0 -1
  112. package/dist/types.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/utils.ts"],"sourcesContent":["import { KnockTool } from \"./knock-tool.js\";\nimport { toolPermissions, tools } from \"../lib/tools/index.js\";\nimport { ToolkitConfig } from \"../types.js\";\nimport { ToolCategory } from \"../types.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 | 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 (hasPermission) {\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 * @param config - The config to use\n * @returns A list of tools for each category that the user has permission to use\n */\nexport function getToolsByPermissionsInCategories(\n config: ToolkitConfig\n): Record<ToolCategory, KnockTool[]> {\n return 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"],"mappings":";;;;;;AAeO,SAAS,YACdA,QACA,SACa;AACb,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAGA,MAAI,YAAY,KAAK;AACnB,WAAO,OAAO,OAAOA,MAAK,EAAE,QAAQ,CAACC,cAAa,OAAO,OAAOA,SAAQ,CAAC;AAAA,EAC3E;AAEA,QAAM,CAAC,UAAU,IAAI,IAAI,QAAQ,MAAM,GAAG;AAG1C,MAAI,aAAa,OAAO,SAAS,KAAK;AACpC,WAAO,OAAO,OAAOD,MAAK,EAAE,QAAQ,CAACC,cAAa,OAAO,OAAOA,SAAQ,CAAC;AAAA,EAC3E;AAEA,MAAI,YAAY,CAACD,OAAM,QAAQ,GAAG;AAChC,UAAM,IAAI,MAAM,iBAAiB,QAAQ,YAAY;AAAA,EACvD;AAGA,MAAI,YAAY,SAAS,KAAK;AAC5B,WAAO,OAAO,OAAOA,OAAM,QAAQ,CAAC;AAAA,EACtC;AAGA,MAAI,YAAY,QAAQ,CAACA,OAAM,QAAQ,EAAE,IAAI,GAAG;AAC9C,UAAM,IAAI,MAAM,QAAQ,OAAO,YAAY;AAAA,EAC7C;AAEA,SAAO,CAACA,OAAM,QAAQ,EAAE,IAAI,CAAC;AAC/B;AASO,SAAS,wBACd,UACA,qBACA;AAEA,QAAM,kBAAkB,MAAM,QAAQ;AACtC,QAAM,4BAA4B,gBAAgB,QAAQ;AAO1D,SAAO,OAAO,QAAQ,mBAAmB,EAAE;AAAA,IACzC,CAAC,KAAkB,CAAC,gBAAgB,aAAa,MAAM;AACrD,UAAI,eAAe;AACjB,eAAO,IAAI;AAAA,UACT,0BAA0B,cAAc,EAAE;AAAA,YACxC,CAAC,aAAa,gBAAgB,QAAQ;AAAA,UACxC;AAAA,QACF;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;AAQO,SAAS,kCACd,QACmC;AACnC,SAAO,OAAO,KAAK,OAAO,WAAW,EAAE;AAAA,IACrC,CAAC,KAAK,aAAa;AACjB,YAAM,cAAc;AACpB,YAAM,sBAAsB,OAAO,YAAY,WAAW;AAE1D,UAAI,MAAM,WAAW,KAAK,qBAAqB;AAC7C,cAAMA,SAAQ,wBAAwB,aAAa,mBAAmB;AAEtE,eAAO,EAAE,GAAG,KAAK,CAAC,WAAW,GAAGA,OAAM;AAAA,MACxC;AAEA,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AACF;","names":["tools","category"]}
@@ -1,15 +0,0 @@
1
- // src/ai-sdk/tool-converter.ts
2
- import { tool } from "ai";
3
- import { z } from "zod";
4
- var knockToolToAiTool = (knockClient, config, knockTool) => {
5
- return tool({
6
- description: knockTool.description,
7
- parameters: knockTool.parameters ?? z.object({}),
8
- execute: knockTool.bindExecute(knockClient, config)
9
- });
10
- };
11
-
12
- export {
13
- knockToolToAiTool
14
- };
15
- //# sourceMappingURL=chunk-6H3BXH2Y.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ai-sdk/tool-converter.ts"],"sourcesContent":["import type { Tool } from \"ai\";\nimport { tool } from \"ai\";\nimport { KnockClient } from \"../lib/knock-client.js\";\nimport { KnockTool } from \"../lib/knock-tool.js\";\nimport { Config } from \"../types.js\";\nimport { z } from \"zod\";\n\n/**\n * Convert a KnockTool to an AI Tool, ready to pass to the AI SDK.\n */\nconst knockToolToAiTool = (\n knockClient: KnockClient,\n config: Config,\n knockTool: KnockTool\n): Tool => {\n return tool({\n description: knockTool.description,\n parameters: knockTool.parameters ?? z.object({}),\n execute: knockTool.bindExecute(knockClient, config),\n });\n};\n\nexport { knockToolToAiTool };\n"],"mappings":";AACA,SAAS,YAAY;AAIrB,SAAS,SAAS;AAKlB,IAAM,oBAAoB,CACxB,aACA,QACA,cACS;AACT,SAAO,KAAK;AAAA,IACV,aAAa,UAAU;AAAA,IACvB,YAAY,UAAU,cAAc,EAAE,OAAO,CAAC,CAAC;AAAA,IAC/C,SAAS,UAAU,YAAY,aAAa,MAAM;AAAA,EACpD,CAAC;AACH;","names":[]}
@@ -1,39 +0,0 @@
1
- import {
2
- KnockTool
3
- } from "./chunk-TOBLV65T.js";
4
-
5
- // src/lib/tools/partials.ts
6
- import { z } from "zod";
7
- var listPartials = KnockTool({
8
- method: "list_partials",
9
- name: "List partials",
10
- 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.
11
-
12
- 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.`,
13
- parameters: z.object({
14
- environment: z.string().describe(
15
- "(string): The environment to list partials for. Defaults to `development`."
16
- )
17
- }),
18
- execute: (knockClient, config) => async (params) => {
19
- const allPartials = [];
20
- for await (const partial of knockClient.partials.list({
21
- environment: params.environment ?? config.environment ?? "development"
22
- })) {
23
- allPartials.push(partial);
24
- }
25
- return allPartials;
26
- }
27
- });
28
- var partials = {
29
- listPartials
30
- };
31
- var permissions = {
32
- read: ["listPartials"]
33
- };
34
-
35
- export {
36
- partials,
37
- permissions
38
- };
39
- //# sourceMappingURL=chunk-BY4KQPUO.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/partials.ts"],"sourcesContent":["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;AAGlB,IAAM,eAAe,UAAU;AAAA,EAC7B,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,EACJ,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,UAAM,cAAyB,CAAC;AAChC,qBAAiB,WAAW,YAAY,SAAS,KAAK;AAAA,MACpD,aAAa,OAAO,eAAe,OAAO,eAAe;AAAA,IAC3D,CAAC,GAAG;AACF,kBAAY,KAAK,OAAO;AAAA,IAC1B;AACA,WAAO;AAAA,EACT;AACF,CAAC;AAEM,IAAM,WAAW;AAAA,EACtB;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,cAAc;AACvB;","names":[]}
@@ -1,39 +0,0 @@
1
- import {
2
- KnockTool
3
- } from "./chunk-TOBLV65T.js";
4
-
5
- // src/lib/tools/email-layouts.ts
6
- import { z } from "zod";
7
- var listEmailLayouts = KnockTool({
8
- method: "list_email_layouts",
9
- name: "List email layouts",
10
- description: `List all email layouts within the environment given. Returns information about the email layout, including the name and the key.
11
-
12
- Use this tool when building a workflow that is building an email notification when you need to know the available email layouts.`,
13
- parameters: z.object({
14
- environment: z.string().describe(
15
- "(string): The environment to list email layouts for. Defaults to `development`."
16
- )
17
- }),
18
- execute: (knockClient, config) => async (params) => {
19
- const allEmailLayouts = [];
20
- for await (const emailLayout of knockClient.emailLayouts.list({
21
- environment: params.environment ?? config.environment ?? "development"
22
- })) {
23
- allEmailLayouts.push(emailLayout);
24
- }
25
- return allEmailLayouts;
26
- }
27
- });
28
- var emailLayouts = {
29
- listEmailLayouts
30
- };
31
- var permissions = {
32
- read: ["listEmailLayouts"]
33
- };
34
-
35
- export {
36
- emailLayouts,
37
- permissions
38
- };
39
- //# sourceMappingURL=chunk-DSRTYV37.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/email-layouts.ts"],"sourcesContent":["import { EmailLayout } from \"@knocklabs/mgmt/resources/email-layouts.js\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { z } from \"zod\";\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 .describe(\n \"(string): The environment to list email layouts for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allEmailLayouts: EmailLayout[] = [];\n for await (const emailLayout of knockClient.emailLayouts.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allEmailLayouts.push(emailLayout);\n }\n return allEmailLayouts;\n },\n});\n\nexport const emailLayouts = {\n listEmailLayouts,\n};\n\nexport const permissions = {\n read: [\"listEmailLayouts\"],\n};\n"],"mappings":";;;;;AAEA,SAAS,SAAS;AAElB,IAAM,mBAAmB,UAAU;AAAA,EACjC,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,EACJ,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,UAAM,kBAAiC,CAAC;AACxC,qBAAiB,eAAe,YAAY,aAAa,KAAK;AAAA,MAC5D,aAAa,OAAO,eAAe,OAAO,eAAe;AAAA,IAC3D,CAAC,GAAG;AACF,sBAAgB,KAAK,WAAW;AAAA,IAClC;AACA,WAAO;AAAA,EACT;AACF,CAAC;AAEM,IAAM,eAAe;AAAA,EAC1B;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,kBAAkB;AAC3B;","names":[]}
@@ -1,75 +0,0 @@
1
- import {
2
- KnockTool
3
- } from "./chunk-TOBLV65T.js";
4
-
5
- // src/lib/tools/tenants.ts
6
- import { z } from "zod";
7
- var getTenant = KnockTool({
8
- method: "get_tenant",
9
- name: "Get tenant",
10
- description: `
11
- 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.
12
-
13
- Use this tool when you need to lookup the information about a tenant, including name, and if there are any custom properties set.
14
- `,
15
- parameters: z.object({
16
- tenantId: z.string().describe("(string): The ID of the tenant to retrieve.")
17
- }),
18
- execute: (knockClient) => async (params) => {
19
- const publicClient = await knockClient.publicApi();
20
- return await publicClient.tenants.get(params.tenantId);
21
- }
22
- });
23
- var setTenant = KnockTool({
24
- method: "set_tenant",
25
- name: "Set tenant",
26
- description: `
27
- 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.
28
-
29
- Use this tool when you need to create a new tenant, or update an existing tenant's properties.
30
- `,
31
- parameters: z.object({
32
- tenantId: z.string().describe("(string): The ID of the tenant to update."),
33
- name: z.string().describe("(string): The name of the tenant."),
34
- properties: z.record(z.string(), z.any()).describe("(object): The properties to set on the tenant.")
35
- }),
36
- execute: (knockClient) => async (params) => {
37
- const publicClient = await knockClient.publicApi();
38
- return await publicClient.tenants.set(params.tenantId, {
39
- name: params.name,
40
- ...params.properties
41
- });
42
- }
43
- });
44
- var deleteTenant = KnockTool({
45
- method: "delete_tenant",
46
- name: "Delete tenant",
47
- description: `
48
- Deletes a tenant. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.
49
-
50
- Use this tool when you've been asked to remove a tenant from the system.
51
- `,
52
- parameters: z.object({
53
- tenantId: z.string().describe("(string): The ID of the tenant to delete.")
54
- }),
55
- execute: (knockClient) => async (params) => {
56
- const publicClient = await knockClient.publicApi();
57
- await publicClient.tenants.delete(params.tenantId);
58
- return { success: true };
59
- }
60
- });
61
- var tenants = {
62
- getTenant,
63
- setTenant,
64
- deleteTenant
65
- };
66
- var permissions = {
67
- read: ["getTenant"],
68
- manage: ["setTenant", "deleteTenant"]
69
- };
70
-
71
- export {
72
- tenants,
73
- permissions
74
- };
75
- //# sourceMappingURL=chunk-JTYQTWCX.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/tenants.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"],"mappings":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,YAAY,UAAU;AAAA,EAC1B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAY,EAAE,OAAO;AAAA,IACnB,UAAU,EACP,OAAO,EACP,SAAS,6CAA6C;AAAA,EAC3D,CAAC;AAAA,EACD,SAAS,CAAC,gBAAgB,OAAO,WAAW;AAC1C,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,WAAO,MAAM,aAAa,QAAQ,IAAI,OAAO,QAAQ;AAAA,EACvD;AACF,CAAC;AAED,IAAM,YAAY,UAAU;AAAA,EAC1B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAY,EAAE,OAAO;AAAA,IACnB,UAAU,EAAE,OAAO,EAAE,SAAS,2CAA2C;AAAA,IACzE,MAAM,EAAE,OAAO,EAAE,SAAS,mCAAmC;AAAA,IAC7D,YAAY,EACT,OAAO,EAAE,OAAO,GAAG,EAAE,IAAI,CAAC,EAC1B,SAAS,gDAAgD;AAAA,EAC9D,CAAC;AAAA,EACD,SAAS,CAAC,gBAAgB,OAAO,WAAW;AAC1C,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,WAAO,MAAM,aAAa,QAAQ,IAAI,OAAO,UAAU;AAAA,MACrD,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,YAAY,EAAE,OAAO;AAAA,IACnB,UAAU,EAAE,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":[]}
@@ -1,92 +0,0 @@
1
- import {
2
- messageTypes,
3
- permissions as permissions6
4
- } from "./chunk-THLK376Y.js";
5
- import {
6
- messages,
7
- permissions as permissions5
8
- } from "./chunk-OD5VHBGN.js";
9
- import {
10
- objects,
11
- permissions as permissions7
12
- } from "./chunk-RYMJEH6P.js";
13
- import {
14
- partials,
15
- permissions as permissions8
16
- } from "./chunk-BY4KQPUO.js";
17
- import {
18
- permissions as permissions9,
19
- tenants
20
- } from "./chunk-JTYQTWCX.js";
21
- import {
22
- permissions as permissions10,
23
- users
24
- } from "./chunk-VJFA3ZVW.js";
25
- import {
26
- permissions as permissions11,
27
- workflows
28
- } from "./chunk-XRQWR3LY.js";
29
- import {
30
- channels,
31
- permissions
32
- } from "./chunk-2CNJ4XX6.js";
33
- import {
34
- commits,
35
- permissions as permissions2
36
- } from "./chunk-TLHETJRF.js";
37
- import {
38
- emailLayouts,
39
- permissions as permissions3
40
- } from "./chunk-DSRTYV37.js";
41
- import {
42
- environments,
43
- permissions as permissions4
44
- } from "./chunk-O6DWF42E.js";
45
-
46
- // src/lib/tools/index.ts
47
- var tools = {
48
- channels,
49
- commits,
50
- emailLayouts,
51
- environments,
52
- messages,
53
- messageTypes,
54
- objects,
55
- partials,
56
- tenants,
57
- users,
58
- workflows
59
- };
60
- var allTools = {
61
- ...channels,
62
- ...commits,
63
- ...emailLayouts,
64
- ...environments,
65
- ...messageTypes,
66
- ...messages,
67
- ...objects,
68
- ...partials,
69
- ...tenants,
70
- ...users,
71
- ...workflows
72
- };
73
- var toolPermissions = {
74
- channels: permissions,
75
- commits: permissions2,
76
- emailLayouts: permissions3,
77
- environments: permissions4,
78
- messages: permissions5,
79
- messageTypes: permissions6,
80
- objects: permissions7,
81
- partials: permissions8,
82
- tenants: permissions9,
83
- users: permissions10,
84
- workflows: permissions11
85
- };
86
-
87
- export {
88
- tools,
89
- allTools,
90
- toolPermissions
91
- };
92
- //# sourceMappingURL=chunk-NZB2TMJW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/index.ts"],"sourcesContent":["import { channels, permissions as channelsPermissions } from \"./channels.js\";\nimport { commits, permissions as commitsPermissions } from \"./commits.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 { messages, permissions as messagesPermissions } from \"./messages.js\";\nimport {\n messageTypes,\n permissions as messageTypesPermissions,\n} from \"./message-types.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 emailLayouts,\n environments,\n messages,\n messageTypes,\n objects,\n partials,\n tenants,\n users,\n workflows,\n};\n\nexport const allTools = {\n ...channels,\n ...commits,\n ...emailLayouts,\n ...environments,\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 emailLayouts: emailLayoutsPermissions,\n environments: environmentsPermissions,\n messages: messagesPermissions,\n messageTypes: messageTypesPermissions,\n objects: objectsPermissions,\n partials: partialsPermissions,\n tenants: tenantsPermissions,\n users: usersPermissions,\n workflows: workflowsPermissions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,IAAM,QAAQ;AAAA,EACnB;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;AACL;AAEO,IAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,EACV,SAASA;AAAA,EACT,cAAcA;AAAA,EACd,cAAcA;AAAA,EACd,UAAUA;AAAA,EACV,cAAcA;AAAA,EACd,SAASA;AAAA,EACT,UAAUA;AAAA,EACV,SAASA;AAAA,EACT,OAAOA;AAAA,EACP,WAAWA;AACb;","names":["permissions"]}
@@ -1,31 +0,0 @@
1
- import {
2
- KnockTool
3
- } from "./chunk-TOBLV65T.js";
4
-
5
- // src/lib/tools/environments.ts
6
- var listEnvironments = KnockTool({
7
- method: "list_environments",
8
- name: "List environments",
9
- description: `
10
- Lists all environments available, returning the slug, name, and the order of each environment. Use this tool when you need to see what environments are available to deploy to.
11
- `,
12
- execute: (knockClient) => async (params) => {
13
- const allEnvironments = [];
14
- for await (const environment of knockClient.environments.list()) {
15
- allEnvironments.push(environment);
16
- }
17
- return allEnvironments;
18
- }
19
- });
20
- var environments = {
21
- listEnvironments
22
- };
23
- var permissions = {
24
- read: ["listEnvironments"]
25
- };
26
-
27
- export {
28
- environments,
29
- permissions
30
- };
31
- //# sourceMappingURL=chunk-O6DWF42E.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/environments.ts"],"sourcesContent":["import { Environment } from \"@knocklabs/mgmt/resources/environments.js\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listEnvironments = KnockTool({\n method: \"list_environments\",\n name: \"List environments\",\n description: `\n Lists all environments available, returning the slug, name, and the order of each environment. Use this tool when you need to see what environments are available to deploy to.\n `,\n execute: (knockClient) => async (params) => {\n const allEnvironments: Environment[] = [];\n for await (const environment of knockClient.environments.list()) {\n allEnvironments.push(environment);\n }\n return allEnvironments;\n },\n});\n\nexport const environments = {\n listEnvironments,\n};\n\nexport const permissions = {\n read: [\"listEnvironments\"],\n};\n"],"mappings":";;;;;AAGA,IAAM,mBAAmB,UAAU;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,SAAS,CAAC,gBAAgB,OAAO,WAAW;AAC1C,UAAM,kBAAiC,CAAC;AACxC,qBAAiB,eAAe,YAAY,aAAa,KAAK,GAAG;AAC/D,sBAAgB,KAAK,WAAW;AAAA,IAClC;AACA,WAAO;AAAA,EACT;AACF,CAAC;AAEM,IAAM,eAAe;AAAA,EAC1B;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,kBAAkB;AAC3B;","names":[]}
@@ -1,32 +0,0 @@
1
- import {
2
- KnockTool
3
- } from "./chunk-TOBLV65T.js";
4
-
5
- // src/lib/tools/messages.ts
6
- import { z } from "zod";
7
- var getMessageContent = KnockTool({
8
- method: "get_message_content",
9
- name: "Get message content",
10
- description: `
11
- 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.
12
- `,
13
- parameters: z.object({
14
- messageId: z.string().describe("(string): The messageId of the message to retrieve.")
15
- }),
16
- execute: (knockClient) => async (params) => {
17
- const publicClient = await knockClient.publicApi();
18
- return await publicClient.messages.getContent(params.messageId);
19
- }
20
- });
21
- var messages = {
22
- getMessageContent
23
- };
24
- var permissions = {
25
- read: ["getMessageContent"]
26
- };
27
-
28
- export {
29
- messages,
30
- permissions
31
- };
32
- //# sourceMappingURL=chunk-OD5VHBGN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/messages.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"],"mappings":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,oBAAoB,UAAU;AAAA,EAClC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,WAAW,EACR,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":[]}
@@ -1,19 +0,0 @@
1
- import {
2
- allTools
3
- } from "./chunk-NZB2TMJW.js";
4
- import {
5
- KnockMcpServer
6
- } from "./chunk-XUYE3AGB.js";
7
-
8
- // src/modelcontextprotocol/index.ts
9
- var createKnockMcpServer = async (params) => {
10
- const { tools, knockClient, config } = params;
11
- return Promise.resolve(
12
- new KnockMcpServer(knockClient, config, tools || Object.values(allTools))
13
- );
14
- };
15
-
16
- export {
17
- createKnockMcpServer
18
- };
19
- //# sourceMappingURL=chunk-PDMA6RIB.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,140 +0,0 @@
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
@@ -1 +0,0 @@
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":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,cAAc,UAAU;AAAA,EAC5B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY,EAAE,OAAO;AAAA,IACnB,YAAY,EACT,OAAO,EACP,SAAS,gDAAgD;AAAA,EAC9D,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,WAAO,MAAM,aAAa,QAAQ,KAAK,OAAO,UAAU;AAAA,EAC1D;AACF,CAAC;AAED,IAAM,YAAY,UAAU;AAAA,EAC1B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY,EAAE,OAAO;AAAA,IACnB,YAAY,EACT,OAAO,EACP,SAAS,kDAAkD;AAAA,IAC9D,UAAU,EAAE,OAAO,EAAE,SAAS,wCAAwC;AAAA,EACxE,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,WAAO,MAAM,aAAa,QAAQ,IAAI,OAAO,YAAY,OAAO,QAAQ;AAAA,EAC1E;AACF,CAAC;AAED,IAAM,uBAAuB,UAAU;AAAA,EACrC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,YAAY,EACT,OAAO,EACP,SAAS,6DAA6D;AAAA,IACzE,UAAU,EACP,OAAO,EACP,SAAS,qDAAqD;AAAA,IACjE,YAAY,EACT,OAAO,EAAE,OAAO,GAAG,EAAE,IAAI,CAAC,EAC1B,SAAS,gDAAgD;AAAA,EAC9D,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,OAAO;AAAA,IACT;AAAA,EACF;AACF,CAAC;AAED,IAAM,eAAe,UAAU;AAAA,EAC7B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY,EAAE,OAAO;AAAA,IACnB,YAAY,EACT,OAAO,EACP,SAAS,qDAAqD;AAAA,IACjE,UAAU,EAAE,OAAO,EAAE,SAAS,2CAA2C;AAAA,EAC3E,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,UAAM,eAAe,MAAM,YAAY,UAAU;AACjD,UAAM,aAAa,QAAQ,OAAO,OAAO,YAAY,OAAO,QAAQ;AACpE,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB;AACF,CAAC;AAED,IAAM,yBAAyB,UAAU;AAAA,EACvC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOb,YAAY,EAAE,OAAO;AAAA,IACnB,YAAY,EACT,OAAO,EACP,SAAS,oDAAoD;AAAA,IAChE,UAAU,EACP,OAAO,EACP,SAAS,0DAA0D;AAAA,IACtE,SAAS,EACN,MAAM,EAAE,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;AAED,IAAM,6BAA6B,UAAU;AAAA,EAC3C,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,YAAY,EACT,OAAO,EACP,SAAS,wDAAwD;AAAA,IACpE,UAAU,EACP,OAAO,EACP,SAAS,8DAA8D;AAAA,IAC1E,SAAS,EACN,MAAM,EAAE,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":[]}