@knocklabs/agent-toolkit 0.1.6 → 0.1.7

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.
@@ -1,4 +1,4 @@
1
- import { T as ToolkitConfig, a as ToolCategory } from '../types-BePFw9M2.js';
1
+ import { T as ToolkitConfig, a as ToolCategory } from '../types-DmmGlWVt.js';
2
2
  import { ToolSet } from 'ai';
3
3
 
4
4
  declare const createKnockToolkit: (config: ToolkitConfig) => {
@@ -1,8 +1,9 @@
1
1
  import {
2
- createKnockClient,
2
+ createKnockClient
3
+ } from "../chunk-CXOB4H3U.js";
4
+ import {
3
5
  getToolsByPermissionsInCategories
4
- } from "../chunk-NOMOK3LZ.js";
5
- import "../chunk-3NU2K26A.js";
6
+ } from "../chunk-3CUTEODM.js";
6
7
 
7
8
  // src/ai-sdk/tool-converter.ts
8
9
  import { tool } from "ai";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ai-sdk/tool-converter.ts","../../src/ai-sdk/index.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","import { ToolCategory, ToolkitConfig } from \"../types.js\";\nimport { getToolsByPermissionsInCategories } from \"../lib/utils.js\";\nimport { createKnockClient } from \"../lib/knock-client.js\";\nimport { ToolSet } from \"ai\";\nimport { knockToolToAiTool } from \"./tool-converter.js\";\n\nconst createKnockToolkit = (config: ToolkitConfig) => {\n const knockClient = createKnockClient(config);\n const allowedToolsByCategory = getToolsByPermissionsInCategories(config);\n\n return {\n /**\n * Get all tools for all categories\n * @returns An array of all tools\n */\n getAllTools: (): ToolSet => {\n return Object.values(allowedToolsByCategory)\n .flat()\n .reduce(\n (acc, tool) => ({\n ...acc,\n [tool.method]: knockToolToAiTool(knockClient, config, tool),\n }),\n {} as ToolSet\n );\n },\n\n /**\n * Get all tools for a specific category\n * @param category - The category of tools to get\n * @returns An array of tools for the given category\n */\n getTools: (category: ToolCategory): ToolSet => {\n return allowedToolsByCategory[category].reduce(\n (acc, tool) => ({\n ...acc,\n [tool.method]: knockToolToAiTool(knockClient, config, tool),\n }),\n {} as ToolSet\n );\n },\n };\n};\n\nexport { createKnockToolkit };\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;;;ACdA,IAAM,qBAAqB,CAAC,WAA0B;AACpD,QAAM,cAAc,kBAAkB,MAAM;AAC5C,QAAM,yBAAyB,kCAAkC,MAAM;AAEvE,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,aAAa,MAAe;AAC1B,aAAO,OAAO,OAAO,sBAAsB,EACxC,KAAK,EACL;AAAA,QACC,CAAC,KAAKA,WAAU;AAAA,UACd,GAAG;AAAA,UACH,CAACA,MAAK,MAAM,GAAG,kBAAkB,aAAa,QAAQA,KAAI;AAAA,QAC5D;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,UAAU,CAAC,aAAoC;AAC7C,aAAO,uBAAuB,QAAQ,EAAE;AAAA,QACtC,CAAC,KAAKA,WAAU;AAAA,UACd,GAAG;AAAA,UACH,CAACA,MAAK,MAAM,GAAG,kBAAkB,aAAa,QAAQA,KAAI;AAAA,QAC5D;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["tool"]}
1
+ {"version":3,"sources":["../../src/ai-sdk/tool-converter.ts","../../src/ai-sdk/index.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","import { ToolCategory, ToolkitConfig } from \"../types.js\";\nimport { getToolsByPermissionsInCategories } from \"../lib/utils.js\";\nimport { createKnockClient } from \"../lib/knock-client.js\";\nimport { ToolSet } from \"ai\";\nimport { knockToolToAiTool } from \"./tool-converter.js\";\n\nconst createKnockToolkit = (config: ToolkitConfig) => {\n const knockClient = createKnockClient(config);\n const allowedToolsByCategory = getToolsByPermissionsInCategories(config);\n\n return {\n /**\n * Get all tools for all categories\n * @returns An array of all tools\n */\n getAllTools: (): ToolSet => {\n return Object.values(allowedToolsByCategory)\n .flat()\n .reduce(\n (acc, tool) => ({\n ...acc,\n [tool.method]: knockToolToAiTool(knockClient, config, tool),\n }),\n {} as ToolSet\n );\n },\n\n /**\n * Get all tools for a specific category\n * @param category - The category of tools to get\n * @returns An array of tools for the given category\n */\n getTools: (category: ToolCategory): ToolSet => {\n return allowedToolsByCategory[category].reduce(\n (acc, tool) => ({\n ...acc,\n [tool.method]: knockToolToAiTool(knockClient, config, tool),\n }),\n {} as ToolSet\n );\n },\n };\n};\n\nexport { createKnockToolkit };\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;;;ACdA,IAAM,qBAAqB,CAAC,WAA0B;AACpD,QAAM,cAAc,kBAAkB,MAAM;AAC5C,QAAM,yBAAyB,kCAAkC,MAAM;AAEvE,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,aAAa,MAAe;AAC1B,aAAO,OAAO,OAAO,sBAAsB,EACxC,KAAK,EACL;AAAA,QACC,CAAC,KAAKA,WAAU;AAAA,UACd,GAAG;AAAA,UACH,CAACA,MAAK,MAAM,GAAG,kBAAkB,aAAa,QAAQA,KAAI;AAAA,QAC5D;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,UAAU,CAAC,aAAoC;AAC7C,aAAO,uBAAuB,QAAQ,EAAE;AAAA,QACtC,CAAC,KAAKA,WAAU;AAAA,UACd,GAAG;AAAA,UACH,CAACA,MAAK,MAAM,GAAG,kBAAkB,aAAa,QAAQA,KAAI;AAAA,QAC5D;AAAA,QACA,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;","names":["tool"]}
@@ -25,6 +25,14 @@ var KnockTool = (args) => {
25
25
  };
26
26
 
27
27
  // src/lib/tools/channels.ts
28
+ function serializeChannelResponse(channel) {
29
+ return {
30
+ key: channel.key,
31
+ name: channel.name,
32
+ type: channel.type,
33
+ provider: channel.provider
34
+ };
35
+ }
28
36
  var listChannels = KnockTool({
29
37
  method: "list_channels",
30
38
  name: "List channels",
@@ -36,7 +44,7 @@ var listChannels = KnockTool({
36
44
  execute: (knockClient) => async (params) => {
37
45
  const allChannels = [];
38
46
  for await (const channel of knockClient.channels.list()) {
39
- allChannels.push(channel);
47
+ allChannels.push(serializeChannelResponse(channel));
40
48
  }
41
49
  return allChannels;
42
50
  }
@@ -117,6 +125,12 @@ var permissions2 = {
117
125
 
118
126
  // src/lib/tools/email-layouts.ts
119
127
  import { z as z3 } from "zod";
128
+ function serializeEmailLayoutResponse(emailLayout) {
129
+ return {
130
+ key: emailLayout.key,
131
+ name: emailLayout.name
132
+ };
133
+ }
120
134
  var listEmailLayouts = KnockTool({
121
135
  method: "list_email_layouts",
122
136
  name: "List email layouts",
@@ -133,7 +147,7 @@ var listEmailLayouts = KnockTool({
133
147
  for await (const emailLayout of knockClient.emailLayouts.list({
134
148
  environment: params.environment ?? config.environment ?? "development"
135
149
  })) {
136
- allEmailLayouts.push(emailLayout);
150
+ allEmailLayouts.push(serializeEmailLayoutResponse(emailLayout));
137
151
  }
138
152
  return allEmailLayouts;
139
153
  }
@@ -146,16 +160,22 @@ var permissions3 = {
146
160
  };
147
161
 
148
162
  // src/lib/tools/environments.ts
163
+ function serializeEnvironmentResponse(environment) {
164
+ return {
165
+ slug: environment.slug,
166
+ name: environment.name
167
+ };
168
+ }
149
169
  var listEnvironments = KnockTool({
150
170
  method: "list_environments",
151
171
  name: "List environments",
152
172
  description: `
153
- 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.
173
+ Lists all environments available, returning the slug and name of each environment. Use this tool when you need to see what environments are available.
154
174
  `,
155
175
  execute: (knockClient) => async (params) => {
156
176
  const allEnvironments = [];
157
177
  for await (const environment of knockClient.environments.list()) {
158
- allEnvironments.push(environment);
178
+ allEnvironments.push(serializeEnvironmentResponse(environment));
159
179
  }
160
180
  return allEnvironments;
161
181
  }
@@ -195,6 +215,14 @@ var permissions5 = {
195
215
 
196
216
  // src/lib/tools/message-types.ts
197
217
  import { z as z5 } from "zod";
218
+ function serializeMessageTypeResponse(messageType) {
219
+ return {
220
+ key: messageType.key,
221
+ name: messageType.name,
222
+ description: messageType.description,
223
+ variants: messageType.variants.map((variant) => variant.key)
224
+ };
225
+ }
198
226
  var listMessageTypes = KnockTool({
199
227
  method: "list_message_types",
200
228
  name: "List message types",
@@ -209,7 +237,7 @@ var listMessageTypes = KnockTool({
209
237
  for await (const messageType of knockClient.messageTypes.list({
210
238
  environment: params.environment ?? config.environment ?? "development"
211
239
  })) {
212
- allMessageTypes.push(messageType);
240
+ allMessageTypes.push(serializeMessageTypeResponse(messageType));
213
241
  }
214
242
  return allMessageTypes;
215
243
  }
@@ -493,6 +521,14 @@ var permissions7 = {
493
521
 
494
522
  // src/lib/tools/partials.ts
495
523
  import { z as z7 } from "zod";
524
+ function serializePartial(partial) {
525
+ return {
526
+ key: partial.key,
527
+ type: partial.type,
528
+ name: partial.name,
529
+ description: partial.description
530
+ };
531
+ }
496
532
  var listPartials = KnockTool({
497
533
  method: "list_partials",
498
534
  name: "List partials",
@@ -509,7 +545,7 @@ var listPartials = KnockTool({
509
545
  for await (const partial of knockClient.partials.list({
510
546
  environment: params.environment ?? config.environment ?? "development"
511
547
  })) {
512
- allPartials.push(partial);
548
+ allPartials.push(serializePartial(partial));
513
549
  }
514
550
  return allPartials;
515
551
  }
@@ -596,6 +632,78 @@ var permissions9 = {
596
632
 
597
633
  // src/lib/tools/users.ts
598
634
  import { z as z9 } from "zod";
635
+
636
+ // src/lib/utils.ts
637
+ function filterTools(tools2, pattern) {
638
+ if (!pattern) {
639
+ throw new Error("No pattern provided");
640
+ }
641
+ if (pattern === "*") {
642
+ return Object.values(tools2).flatMap((category2) => Object.values(category2));
643
+ }
644
+ const [category, tool] = pattern.split(".");
645
+ if (category === "*" && tool === "*") {
646
+ return Object.values(tools2).flatMap((category2) => Object.values(category2));
647
+ }
648
+ if (category && !tools2[category]) {
649
+ throw new Error(`Tool category ${category} not found`);
650
+ }
651
+ if (category && tool === "*") {
652
+ return Object.values(tools2[category]);
653
+ }
654
+ if (category && tool && !tools2[category][tool]) {
655
+ throw new Error(`Tool ${pattern} not found`);
656
+ }
657
+ return [tools2[category][tool]];
658
+ }
659
+ function getToolsWithPermissions(category, categoryPermissions) {
660
+ const toolsInCategory = tools[category];
661
+ const toolPermissionsInCategory = toolPermissions[category];
662
+ return Object.entries(categoryPermissions).reduce(
663
+ (acc, [permissionType, hasPermission]) => {
664
+ if (hasPermission) {
665
+ return acc.concat(
666
+ toolPermissionsInCategory[permissionType].map(
667
+ (toolName) => toolsInCategory[toolName]
668
+ )
669
+ );
670
+ }
671
+ return acc;
672
+ },
673
+ []
674
+ );
675
+ }
676
+ function getToolsByPermissionsInCategories(config) {
677
+ return Object.keys(config.permissions).reduce(
678
+ (acc, category) => {
679
+ const categoryKey = category;
680
+ const categoryPermissions = config.permissions[categoryKey];
681
+ if (tools[categoryKey] && categoryPermissions) {
682
+ const tools2 = getToolsWithPermissions(categoryKey, categoryPermissions);
683
+ return { ...acc, [categoryKey]: tools2 };
684
+ }
685
+ return acc;
686
+ },
687
+ {}
688
+ );
689
+ }
690
+ function serializeMessageResponse(message) {
691
+ return {
692
+ id: message.id,
693
+ status: message.status,
694
+ engagement_statuses: message.engagement_statuses,
695
+ data: message.data,
696
+ metadata: message.metadata
697
+ };
698
+ }
699
+
700
+ // src/lib/tools/users.ts
701
+ function maybeHideUserData(user, hideUserData = false) {
702
+ if (hideUserData) {
703
+ return { id: user.id };
704
+ }
705
+ return user;
706
+ }
599
707
  var getUser = KnockTool({
600
708
  method: "get_user",
601
709
  name: "Get user",
@@ -612,7 +720,8 @@ var getUser = KnockTool({
612
720
  }),
613
721
  execute: (knockClient, config) => async (params) => {
614
722
  const publicClient = await knockClient.publicApi(params.environment);
615
- return await publicClient.users.get(params.userId ?? config.userId);
723
+ const user = await publicClient.users.get(params.userId ?? config.userId);
724
+ return maybeHideUserData(user, config.hideUserData);
616
725
  }
617
726
  });
618
727
  var createOrUpdateUser = KnockTool({
@@ -639,12 +748,16 @@ var createOrUpdateUser = KnockTool({
639
748
  }),
640
749
  execute: (knockClient, config) => async (params) => {
641
750
  const publicClient = await knockClient.publicApi(params.environment);
642
- return await publicClient.users.identify(params.userId ?? config.userId, {
643
- email: params.email,
644
- name: params.name,
645
- phone_number: params.phoneNumber,
646
- ...params.customProperties ?? {}
647
- });
751
+ const user = await publicClient.users.identify(
752
+ params.userId ?? config.userId,
753
+ {
754
+ email: params.email,
755
+ name: params.name,
756
+ phone_number: params.phoneNumber,
757
+ ...params.customProperties ?? {}
758
+ }
759
+ );
760
+ return maybeHideUserData(user, config.hideUserData);
648
761
  }
649
762
  });
650
763
  var getUserPreferences = KnockTool({
@@ -774,12 +887,13 @@ var getUserMessages = KnockTool({
774
887
  }),
775
888
  execute: (knockClient, config) => async (params) => {
776
889
  const publicClient = await knockClient.publicApi(params.environment);
777
- return await publicClient.users.getMessages(
890
+ const messages2 = await publicClient.users.getMessages(
778
891
  params.userId ?? config.userId,
779
892
  {
780
893
  workflow_run_id: params.workflowRunId
781
894
  }
782
895
  );
896
+ return messages2.items.map(serializeMessageResponse);
783
897
  }
784
898
  });
785
899
  var users = {
@@ -796,13 +910,22 @@ var permissions10 = {
796
910
 
797
911
  // src/lib/tools/workflows.ts
798
912
  import { z as z10 } from "zod";
913
+ function serializeWorkflowResponse(workflow) {
914
+ return {
915
+ key: workflow.key,
916
+ name: workflow.name,
917
+ description: workflow.description,
918
+ categories: workflow.categories,
919
+ schema: workflow.trigger_data_json_schema
920
+ };
921
+ }
799
922
  var listWorkflows = KnockTool({
800
923
  method: "list_workflows",
801
924
  name: "List workflows",
802
925
  description: `
803
- List all workflows available for the given environment. Returns structural information about the workflows, including the key, name, description, and categories. Will also return the steps that make up the workflow.
926
+ List all workflows available for the given environment. Returns structural information about the workflows, including the key, name, description, and categories.
804
927
 
805
- Use this tool when you need to understand which workflows are available to be called.
928
+ Use this tool when you need to understand which workflows are available to be called.
806
929
  `,
807
930
  parameters: z10.object({
808
931
  environment: z10.string().optional().describe(
@@ -815,11 +938,30 @@ var listWorkflows = KnockTool({
815
938
  environment: params.environment ?? config.environment ?? "development"
816
939
  };
817
940
  for await (const workflow of knockClient.workflows.list(listParams)) {
818
- allWorkflows.push(workflow);
941
+ allWorkflows.push(serializeWorkflowResponse(workflow));
819
942
  }
820
943
  return allWorkflows;
821
944
  }
822
945
  });
946
+ var getWorkflow = KnockTool({
947
+ method: "get_workflow",
948
+ name: "Get workflow",
949
+ description: `
950
+ Get a workflow by key. Returns structural information about the workflow, including the key, name, description, and categories.
951
+ `,
952
+ parameters: z10.object({
953
+ environment: z10.string().optional().describe(
954
+ "(string): The environment to get the workflow for. Defaults to `development`."
955
+ ),
956
+ workflowKey: z10.string().describe("(string): The key of the workflow to get.")
957
+ }),
958
+ execute: (knockClient, config) => async (params) => {
959
+ const workflow = await knockClient.workflows.retrieve(params.workflowKey, {
960
+ environment: params.environment ?? config.environment ?? "development"
961
+ });
962
+ return serializeWorkflowResponse(workflow);
963
+ }
964
+ });
823
965
  var triggerWorkflow = KnockTool({
824
966
  method: "trigger_workflow",
825
967
  name: "Trigger workflow",
@@ -829,6 +971,8 @@ var triggerWorkflow = KnockTool({
829
971
  Use this tool when you need to trigger a workflow to send a notification across the channels configured for the workflow. The workflow must be committed in the environment for you to trigger it.
830
972
 
831
973
  When recipients aren't provided, the workflow will be triggered for the current user specified in the config.
974
+
975
+ Returns the workflow run ID, which can be used to lookup messages produced by the workflow.
832
976
  `,
833
977
  parameters: z10.object({
834
978
  environment: z10.string().optional().describe(
@@ -923,10 +1067,11 @@ var createEmailWorkflow = KnockTool({
923
1067
  ]
924
1068
  }
925
1069
  };
926
- return await knockClient.workflows.upsert(
1070
+ const result = await knockClient.workflows.upsert(
927
1071
  params.workflowKey,
928
1072
  workflowParams
929
1073
  );
1074
+ return serializeWorkflowResponse(result.workflow);
930
1075
  }
931
1076
  });
932
1077
  var createOneOffWorkflowSchedule = KnockTool({
@@ -967,20 +1112,50 @@ var createOneOffWorkflowSchedule = KnockTool({
967
1112
  });
968
1113
  var workflows = {
969
1114
  listWorkflows,
1115
+ getWorkflow,
970
1116
  triggerWorkflow,
971
1117
  createEmailWorkflow,
972
1118
  createOneOffWorkflowSchedule
973
1119
  };
974
1120
  var permissions11 = {
975
- read: ["listWorkflows"],
1121
+ read: ["listWorkflows", "getWorkflow"],
976
1122
  manage: ["createEmailWorkflow", "createOneOffWorkflowSchedule"],
977
1123
  run: ["triggerWorkflow"]
978
1124
  };
979
1125
 
1126
+ // src/lib/tools/documentation.ts
1127
+ import { z as z11 } from "zod";
1128
+ var searchDocumentation = KnockTool({
1129
+ method: "search_documentation",
1130
+ name: "Search documentation",
1131
+ description: "Search the Knock documentation for a given query",
1132
+ parameters: z11.object({
1133
+ query: z11.string().describe("The query to search the documentation for")
1134
+ }),
1135
+ execute: () => async (params) => {
1136
+ const response = await fetch(`https://docs.knock.app/api/search`, {
1137
+ method: "POST",
1138
+ headers: {
1139
+ "Content-Type": "application/json"
1140
+ },
1141
+ body: JSON.stringify({ query: params.query })
1142
+ });
1143
+ const data = await response.json();
1144
+ return data;
1145
+ }
1146
+ });
1147
+ var documentation = {
1148
+ searchDocumentation
1149
+ };
1150
+ var permissions12 = {
1151
+ read: ["searchDocumentation"]
1152
+ };
1153
+
980
1154
  // src/lib/tools/index.ts
981
1155
  var tools = {
982
1156
  channels,
983
1157
  commits,
1158
+ documentation,
984
1159
  emailLayouts,
985
1160
  environments,
986
1161
  messages,
@@ -994,6 +1169,7 @@ var tools = {
994
1169
  var allTools = {
995
1170
  ...channels,
996
1171
  ...commits,
1172
+ ...documentation,
997
1173
  ...emailLayouts,
998
1174
  ...environments,
999
1175
  ...messageTypes,
@@ -1007,6 +1183,7 @@ var allTools = {
1007
1183
  var toolPermissions = {
1008
1184
  channels: permissions,
1009
1185
  commits: permissions2,
1186
+ documentation: permissions12,
1010
1187
  emailLayouts: permissions3,
1011
1188
  environments: permissions4,
1012
1189
  messages: permissions5,
@@ -1021,6 +1198,7 @@ var toolPermissions = {
1021
1198
  export {
1022
1199
  tools,
1023
1200
  allTools,
1024
- toolPermissions
1201
+ filterTools,
1202
+ getToolsByPermissionsInCategories
1025
1203
  };
1026
- //# sourceMappingURL=chunk-3NU2K26A.js.map
1204
+ //# sourceMappingURL=chunk-3CUTEODM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/knock-tool.ts","../src/lib/tools/channels.ts","../src/lib/tools/commits.ts","../src/lib/tools/email-layouts.ts","../src/lib/tools/environments.ts","../src/lib/tools/messages.ts","../src/lib/tools/message-types.ts","../src/lib/tools/objects.ts","../src/lib/tools/partials.ts","../src/lib/tools/tenants.ts","../src/lib/tools/users.ts","../src/lib/utils.ts","../src/lib/tools/workflows.ts","../src/lib/tools/documentation.ts","../src/lib/tools/index.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 { Channel } from \"@knocklabs/mgmt/resources/channels.js\";\n\n/**\n * A slimmed down version of the Channel resource that is easier to work with in the LLM.\n */\ntype SerializedChannel = {\n key: string;\n name: string;\n type: string;\n provider: string;\n};\n\nfunction serializeChannelResponse(channel: Channel): SerializedChannel {\n return {\n key: channel.key,\n name: channel.name,\n type: channel.type,\n provider: channel.provider,\n };\n}\n\nconst listChannels = KnockTool({\n method: \"list_channels\",\n name: \"List channels\",\n description: `\n Returns a list of all of the channels configured in the account. Each channel returns information about the type of channel it is (email, sms, push, etc), and the provider that's used to power the channel. Channels can be used across all environments.\n\n Use this tool when you need to know about the channels configured in the Knock account, like when configuring a workflow.\n `,\n execute: (knockClient) => async (params) => {\n const allChannels: SerializedChannel[] = [];\n for await (const channel of knockClient.channels.list()) {\n allChannels.push(serializeChannelResponse(channel));\n }\n return allChannels;\n },\n});\n\nexport const channels = {\n listChannels,\n};\n\nexport const permissions = {\n read: [\"listChannels\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listCommits = KnockTool({\n method: \"list_commits\",\n name: \"List commits\",\n description: `\n Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list commits for. Defaults to `development`.\"\n ),\n promoted: z\n .boolean()\n .describe(\n \"(boolean): Whether to only return promoted commits. Defaults to `false`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.list({\n environment: params.environment ?? config.environment ?? \"development\",\n promoted: params.promoted ?? false,\n });\n },\n});\n\nconst commitAllChanges = KnockTool({\n method: \"commit_all_changes\",\n name: \"Commit all changes\",\n description: `\n Commit all pending changes. This can only be used in the development environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to commit all changes to. Defaults to `development`.\"\n ),\n message: z\n .string()\n .optional()\n .describe(\"(string): The message to include in the commit.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.commitAll({\n environment: params.environment ?? config.environment ?? \"development\",\n commit_message: params.message,\n });\n },\n});\n\nconst promoteAllCommits = KnockTool({\n method: \"promote_all_commits\",\n name: \"Promote all commits\",\n description: `\n Promote all commits to the next environment. Use this tool when you are asked to deploy all changes.\n `,\n parameters: z.object({\n toEnvironment: z\n .string()\n .describe(\"(string): The environment to promote all commits to.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.put(\"/v1/commits/promote\", {\n body: { to_environment: params.toEnvironment },\n });\n },\n});\n\nexport const commits = {\n listCommits,\n commitAllChanges,\n promoteAllCommits,\n};\n\nexport const permissions = {\n read: [\"listCommits\"],\n manage: [\"commitAllChanges\", \"promoteAllCommits\"],\n};\n","import { EmailLayout } from \"@knocklabs/mgmt/resources/email-layouts.js\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { z } from \"zod\";\n\n/**\n * A slimmed down version of the EmailLayout resource that is easier to work with in the LLM.\n */\ntype SerializedEmailLayout = {\n key: string;\n name: string;\n};\n\nfunction serializeEmailLayoutResponse(\n emailLayout: EmailLayout\n): SerializedEmailLayout {\n return {\n key: emailLayout.key,\n name: emailLayout.name,\n };\n}\n\nconst listEmailLayouts = KnockTool({\n method: \"list_email_layouts\",\n name: \"List email layouts\",\n description: `List all email layouts within the environment given. Returns information about the email layout, including the name and the key. \n \n Use this tool when building a workflow that is building an email notification when you need to know the available email layouts.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list email layouts for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allEmailLayouts: SerializedEmailLayout[] = [];\n for await (const emailLayout of knockClient.emailLayouts.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allEmailLayouts.push(serializeEmailLayoutResponse(emailLayout));\n }\n return allEmailLayouts;\n },\n});\n\nexport const emailLayouts = {\n listEmailLayouts,\n};\n\nexport const permissions = {\n read: [\"listEmailLayouts\"],\n};\n","import { Environment } from \"@knocklabs/mgmt/resources/environments.js\";\nimport { KnockTool } from \"../knock-tool.js\";\n\n/**\n * A slimmed down version of the Environment resource that is easier to work with in the LLM.\n */\ntype SerializedEnvironment = {\n slug: string;\n name: string;\n};\n\nfunction serializeEnvironmentResponse(\n environment: Environment\n): SerializedEnvironment {\n return {\n slug: environment.slug,\n name: environment.name,\n };\n}\n\nconst listEnvironments = KnockTool({\n method: \"list_environments\",\n name: \"List environments\",\n description: `\n Lists all environments available, returning the slug and name of each environment. Use this tool when you need to see what environments are available.\n `,\n execute: (knockClient) => async (params) => {\n const allEnvironments: SerializedEnvironment[] = [];\n for await (const environment of knockClient.environments.list()) {\n allEnvironments.push(serializeEnvironmentResponse(environment));\n }\n return allEnvironments;\n },\n});\n\nexport const environments = {\n listEnvironments,\n};\n\nexport const permissions = {\n read: [\"listEnvironments\"],\n};\n","import { 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 environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the message from. Defaults to `development`.\"\n ),\n messageId: z\n .string()\n .describe(\"(string): The messageId of the message to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.messages.getContent(params.messageId);\n },\n});\n\nexport const messages = {\n getMessageContent,\n};\n\nexport const permissions = {\n read: [\"getMessageContent\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { MessageType } from \"@knocklabs/mgmt/resources/message-types.js\";\n\n/**\n * A slimmed down version of the MessageType resource that is easier to work with in the LLM.\n */\ntype SerializedMessageType = {\n key: string;\n name: string;\n description?: string | null;\n variants: string[];\n};\n\nfunction serializeMessageTypeResponse(\n messageType: MessageType\n): SerializedMessageType {\n return {\n key: messageType.key,\n name: messageType.name,\n description: messageType.description,\n variants: messageType.variants.map((variant) => variant.key),\n };\n}\nconst listMessageTypes = KnockTool({\n method: \"list_message_types\",\n name: \"List message types\",\n description:\n \"List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list message types for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allMessageTypes: SerializedMessageType[] = [];\n for await (const messageType of knockClient.messageTypes.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allMessageTypes.push(serializeMessageTypeResponse(messageType));\n }\n return allMessageTypes;\n },\n});\n\nconst createOrUpdateMessageType = KnockTool({\n method: \"create_or_update_message_type\",\n name: \"Create or update message type\",\n description: `\n Create or update a message type. A message type is a schema that defines fields available to an editor within Knock. Message types always have at least one variant, that MUST be named \"default\".\n \n Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.\n\n The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named \"text\" will be rendered as {{ text }}.\n\n <example>\n <description>\n Create a new message type for a banner component that has a text and an action URL.\n </description>\n <input>\n {\n \"messageTypeKey\": \"banner\",\n \"name\": \"Banner\",\n \"description\": \"A banner component that has a text and an action URL.\",\n \"preview\": \"<div>{{ text }}</div>\",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"text\",\n \"type\": \"text\",\n \"label\": \"Text\",\n \"settings\": {\n \"max_length\": 100,\n },\n },\n {\n \"key\": \"action_url\",\n \"type\": \"text\",\n \"label\": \"Action URL\",\n \"settings\": {\n \"placeholder\": \"https://example.com\",\n },\n }\n ]\n }\n ]\n }\n </input>\n </example>\n <example>\n <description>\n Create a message type for a card component that has an icon type, title, body, and a single action button.\n </description>\n <input>\n {\n \"messageTypeKey\": \"card\",\n \"name\": \"Card\",\n \"description\": \"A single-action card component.\",\n \"preview\": \"\n <div>\n <h2>{{ title }}</h2>\n <p>{{ body }}</p>\n <button>Action</button>\n </div>\n \",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"icon_type\",\n \"type\": \"select\",\n \"label\": \"Icon type\",\n \"settings\": {\n \"options\": [\n {\n \"value\": \"warning\",\n \"label\": \"Warning\",\n },\n ]\n },\n },\n {\n \"key\": \"description\",\n \"type\": \"markdown\",\n \"label\": \"Description\",\n },\n {\n \"key\": \"action_button\",\n \"type\": \"button\",\n \"label\": \"Action button\",\n },\n ]\n }\n ]\n }\n </input>\n </example>\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the message type in. Defaults to `development`.\"\n ),\n messageTypeKey: z\n .string()\n .describe(\"(string): The key of the message type to create or update.\"),\n name: z.string().describe(\"(string): The name of the message type.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the message type.\"),\n preview: z\n .string()\n .optional()\n .describe(\n \"(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants.\"\n ),\n variants: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the variant.\"),\n name: z.string().describe(\"(string): The name of the variant.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the variant.\"),\n fields: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the field.\"),\n type: z\n .string()\n .describe(\n \"(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`, `image`.\"\n ),\n label: z.string().describe(\"(string): The label of the field.\"),\n settings: z\n .object({})\n .optional()\n .describe(\"(object): The settings of the field.\"),\n })\n )\n .describe(\"(array): The fields of the variant.\"),\n })\n )\n .describe(\"(array): The variants of the message type.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.messageTypes.upsert(params.messageTypeKey, {\n message_type: {\n name: params.name,\n variants: params.variants,\n description: params.description ?? \"\",\n preview: params.preview ?? \"<div></div>\",\n },\n environment: params.environment ?? config.environment ?? \"development\",\n });\n },\n});\n\nexport const messageTypes = {\n listMessageTypes,\n createOrUpdateMessageType,\n};\n\nexport const permissions = {\n read: [\"listMessageTypes\"],\n manage: [\"createOrUpdateMessageType\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listObjects = KnockTool({\n method: \"list_objects\",\n name: \"List objects\",\n description:\n \"List all objects in a single collection. Objects are used to model custom collections in Knock that are NOT users or tenants. Use this tool when you need to return a paginated list of objects in a single collection.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list objects from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to list objects from.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.list(params.collection);\n },\n});\n\nconst getObject = KnockTool({\n method: \"get_object\",\n name: \"Get object\",\n description:\n \"Get an object wihin a collection. Returns information about the object including any custom properties. Use this tool when you need to retrieve an object to understand it's properties.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the object from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to get the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.get(params.collection, params.objectId);\n },\n});\n\nconst createOrUpdateObject = KnockTool({\n method: \"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 environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the object in. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to create or update the object in.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to create or update.\"),\n properties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): The properties to set on the object.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.set(\n params.collection,\n params.objectId,\n params.properties\n );\n },\n});\n\nconst subscribeUsersToObject = KnockTool({\n method: \"subscribe_users_to_object\",\n name: \"Subscribe users to object\",\n description: `\n Subscribe a list of users to an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to subscribe one or more users to an object where you will then trigger workflows for those lists of users to send notifications to.\n\n Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to subscribe the user to. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to subscribe the user to.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to subscribe the user to.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.addSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nconst unsubscribeUsersFromObject = KnockTool({\n method: \"unsubscribe_users_from_object\",\n name: \"Unsubscribe users from object\",\n description: `Unsubscribe a list of users from an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to unsubscribe one or more users from an object where you will then trigger workflows for those lists of users to send notifications to.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to unsubscribe the user from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to unsubscribe the user from.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to unsubscribe the user from.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to unsubscribe from the object.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.deleteSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nexport const objects = {\n listObjects,\n getObject,\n createOrUpdateObject,\n subscribeUsersToObject,\n unsubscribeUsersFromObject,\n};\n\nexport const permissions = {\n read: [\"listObjects\", \"getObject\"],\n manage: [\n \"createOrUpdateObject\",\n \"subscribeUsersToObject\",\n \"unsubscribeUsersFromObject\",\n ],\n};\n","import { KnockTool } from \"../knock-tool.js\";\nimport { z } from \"zod\";\nimport { Partial } from \"@knocklabs/mgmt/resources/partials.js\";\n\n/**\n * A slimmed down version of the Partial resource that is easier to work with in the LLM.\n */\ntype SerializedPartial = {\n key: string;\n type: Partial[\"type\"];\n name: string;\n description?: string;\n};\n\nfunction serializePartial(partial: Partial): SerializedPartial {\n return {\n key: partial.key,\n type: partial.type,\n name: partial.name,\n description: partial.description,\n };\n}\n\nconst listPartials = KnockTool({\n method: \"list_partials\",\n name: \"List partials\",\n description: `\n List all partials within the environment given. Partials provide common building blocks for notification templates. Returns information about the partial, including the name and the key. \n Use this tool when you need to know the available partials for the environment, like when building a notification template and wanting to use a partial to build the template.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list partials for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allPartials: SerializedPartial[] = [];\n for await (const partial of knockClient.partials.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allPartials.push(serializePartial(partial));\n }\n return allPartials;\n },\n});\n\nexport const partials = {\n listPartials,\n};\n\nexport const permissions = {\n read: [\"listPartials\"],\n};\n","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 environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the tenant from. Defaults to `development`.\"\n ),\n tenantId: z\n .string()\n .describe(\"(string): The ID of the tenant to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.get(params.tenantId);\n },\n});\n\nconst listTenants = KnockTool({\n method: \"list_tenants\",\n name: \"List tenants\",\n description: `\n Retrieves a list of tenants. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object. \n \n Use this tool when you need to list all tenants in an environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the tenants from. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.list();\n },\n});\n\nconst 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 environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to set the tenant in. Defaults to `development`.\"\n ),\n tenantId: z.string().describe(\"(string): The ID of the tenant to update.\"),\n name: z.string().optional().describe(\"(string): The name of the tenant.\"),\n properties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): The properties to set on the tenant.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.set(params.tenantId, {\n name: params.name,\n ...params.properties,\n });\n },\n});\n\nexport const tenants = {\n getTenant,\n listTenants,\n setTenant,\n};\n\nexport const permissions = {\n read: [\"getTenant\", \"listTenants\"],\n manage: [\"setTenant\"],\n};\n","import { z } from \"zod\";\nimport { User } from \"@knocklabs/node\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { serializeMessageResponse } from \"../utils.js\";\nfunction maybeHideUserData(user: User, hideUserData: boolean = false) {\n if (hideUserData) {\n return { id: user.id };\n }\n return user;\n}\n\nconst getUser = KnockTool({\n method: \"get_user\",\n name: \"Get user\",\n description: `\n Retrieves the complete user object for the given userId, including email, name, phone number, and any custom properties. Use this tool when you need to retrieve a user's complete profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to retrieve.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const user = await publicClient.users.get(params.userId ?? config.userId);\n\n return maybeHideUserData(user, config.hideUserData);\n },\n});\n\nconst createOrUpdateUser = KnockTool({\n method: \"create_or_update_user\",\n name: \"Create or update user\",\n description: `\n Creates a new user if they don't exist, or updates the user object for the given userId, including email, name, phone number, and any custom properties.\n \n Use this tool when you need to update a user's profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the user in. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to update.\"),\n email: z\n .string()\n .optional()\n .describe(\"(string): The email of the User to update.\"),\n name: z\n .string()\n .optional()\n .describe(\"(string): The name of the User to update.\"),\n phoneNumber: z\n .string()\n .optional()\n .describe(\"(string): The phone number of the User to update.\"),\n customProperties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): A dictionary of custom properties to update for the User.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const user = await publicClient.users.identify(\n params.userId ?? config.userId,\n {\n email: params.email,\n name: params.name,\n phone_number: params.phoneNumber,\n ...(params.customProperties ?? {}),\n }\n );\n\n return maybeHideUserData(user, config.hideUserData);\n },\n});\n\nconst getUserPreferences = KnockTool({\n method: \"get_user_preferences\",\n name: \"Get user preferences\",\n description: `\n Retrieves the user's notification preferences for the given userId.\n\n If the userId is not provided, it will use the userId from the config. \n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user preferences from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\n \"(string): The userId of the User to retrieve Preferences for.\"\n ),\n preferenceSetId: z\n .string()\n .optional()\n .describe(\n \"(string): The preferenceSetId of the User to retrieve preferences for. Defaults to `default`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: params.preferenceSetId ?? \"default\",\n }\n );\n },\n});\n\nconst setUserPreferences = KnockTool({\n method: \"set_user_preferences\",\n name: \"Set user preferences\",\n description: `\n Overwrites the user's notification preferences for the given userId. Allows setting per-workflow, per-category, or per-channel notification preferences. Use this tool when you are asked to update a user's notification preferences.\n\n If the userId is not provided, it will use the userId from the config.\n\n Instructions:\n\n - You must ALWAYS provide a full preference set to this tool.\n - When setting per-workflow preferences, the key in the object should be the workflow key.\n - Workflow and category preferences should always have channel types underneath.\n - The channel types available to you are: email, sms, push, chat, and in_app_feed.\n - To turn OFF a preference, you must set it to false.\n - To turn ON a preference, you must set it to true.\n\n <examples>\n <example>\n <description>\n Update the user's preferences to turn off email notifications for the \"welcome\" workflow.\n </description>\n <input>\n {\n \"workflows\": {\n \"welcome\": {\n \"channel_types\": {\n \"email\": false\n }\n }\n }\n }\n </example>\n </examples>\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to set the user preferences in. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to update preferences for.\"),\n workflows: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The workflows to update where the key is the workflow key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n categories: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The categories to update where the key is the category key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n channel_types: z\n .record(z.string(), z.boolean())\n .optional()\n .describe(\n \"(object): The channel types to update where the key is the channel type, and the value of the object is a boolean value.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const existingPreferences = await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: \"default\",\n }\n );\n\n const updatedPreferences = {\n ...existingPreferences,\n workflows: {\n ...existingPreferences.workflows,\n ...params.workflows,\n },\n categories: {\n ...existingPreferences.categories,\n ...params.categories,\n },\n channel_types: {\n ...existingPreferences.channel_types,\n ...params.channel_types,\n },\n };\n\n return await publicClient.users.setPreferences(\n params.userId ?? config.userId,\n updatedPreferences\n );\n },\n});\n\nconst getUserMessages = KnockTool({\n method: \"get_user_messages\",\n name: \"Get user messages\",\n description: `\n Retrieves the messages that this user has received from the service. Use this tool when you need information about the notifications that the user has received, including if the message has been read, seen, or interacted with. This will return a list of messages across all of the channels.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user messages from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to retrieve messages for.\"),\n workflowRunId: z\n .string()\n .optional()\n .describe(\n \"(string): The workflowRunId of the User to retrieve. Use this when you want to retrieve messages sent from a workflow trigger.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const messages = await publicClient.users.getMessages(\n params.userId ?? config.userId,\n {\n workflow_run_id: params.workflowRunId,\n }\n );\n\n return messages.items.map(serializeMessageResponse);\n },\n});\n\nexport const users = {\n getUser,\n createOrUpdateUser,\n getUserPreferences,\n setUserPreferences,\n getUserMessages,\n};\n\nexport const permissions = {\n read: [\"getUser\", \"getUserMessages\", \"getUserPreferences\"],\n manage: [\"createOrUpdateUser\", \"setUserPreferences\"],\n};\n","import { 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\n/**\n * Serialize a message response from the API to a more LLM-friendly format.\n *\n * @param message - The message to serialize\n * @returns A serialized message\n */\nexport function serializeMessageResponse(message: Record<string, any>) {\n return {\n id: message.id,\n status: message.status,\n engagement_statuses: message.engagement_statuses,\n data: message.data,\n metadata: message.metadata,\n };\n}\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport {\n Workflow,\n WorkflowUpsertParams,\n} from \"@knocklabs/mgmt/resources/index.js\";\n\n/**\n * A slimmed down version of the Workflow resource that is easier to work with in the LLM.\n */\ntype SerializedWorkflow = {\n key: string;\n name: string;\n description: string | undefined;\n categories: string[] | undefined;\n schema: Record<string, unknown> | undefined;\n};\n\nfunction serializeWorkflowResponse(workflow: Workflow): SerializedWorkflow {\n return {\n key: workflow.key,\n name: workflow.name,\n description: workflow.description,\n categories: workflow.categories,\n schema: workflow.trigger_data_json_schema,\n };\n}\n\nconst listWorkflows = KnockTool({\n method: \"list_workflows\",\n name: \"List workflows\",\n description: `\n List all workflows available for the given environment. Returns structural information about the workflows, including the key, name, description, and categories.\n\n Use this tool when you need to understand which workflows are available to be called.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list workflows for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allWorkflows: SerializedWorkflow[] = [];\n const listParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n };\n\n for await (const workflow of knockClient.workflows.list(listParams)) {\n allWorkflows.push(serializeWorkflowResponse(workflow));\n }\n\n return allWorkflows;\n },\n});\n\nconst getWorkflow = KnockTool({\n method: \"get_workflow\",\n name: \"Get workflow\",\n description: `\n Get a workflow by key. Returns structural information about the workflow, including the key, name, description, and categories.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the workflow for. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const workflow = await knockClient.workflows.retrieve(params.workflowKey, {\n environment: params.environment ?? config.environment ?? \"development\",\n });\n\n return serializeWorkflowResponse(workflow);\n },\n});\n\nconst triggerWorkflow = KnockTool({\n method: \"trigger_workflow\",\n name: \"Trigger workflow\",\n description: `\n Trigger a workflow for one or more recipients, which may produce one or more messages for each recipient depending on the workflow's steps.\n\n Use this tool when you need to trigger a workflow to send a notification across the channels configured for the workflow. The workflow must be committed in the environment for you to trigger it.\n\n When recipients aren't provided, the workflow will be triggered for the current user specified in the config.\n\n Returns the workflow run ID, which can be used to lookup messages produced by the workflow.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to trigger the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to trigger.\"),\n recipients: z\n .array(z.string())\n .optional()\n .describe(\n \"(array): The recipients to trigger the workflow for. This is an array of user IDs.\"\n ),\n data: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): Data to pass to the workflow.\"),\n tenant: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The tenant to trigger the workflow for. Must contain an id if being sent.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const result = await publicClient.workflows.trigger(params.workflowKey, {\n recipients: params.recipients ?? [config.userId] ?? [],\n data: params.data,\n tenant: params.tenant ?? config.tenantId,\n });\n\n return result.workflow_run_id;\n },\n});\n\nconst createEmailWorkflow = KnockTool({\n method: \"create_email_workflow\",\n name: \"Create email workflow\",\n description: `\n Creates a simple email workflow with a single step that sends an email to the recipient. Use this tool when you need to need to create an email notification, and you don't need to specify any additional steps. You can only create workflows in the development environment.\n\n The content of the email you supply should ONLY ever be in markdown format for simplicity. You can supply dynamic variables to the subject and body of the email using the liquid template language.\n\n When writing markdown, be sure to use headings (##) to separate sections of the email. Use an informal writing style, and avoid using complex language.\n\n The following variables are available to use in the email subject and body:\n\n - \\`recipient.name\\`: The name of the recipient.\n - \\`recipient.email\\`: The email of the recipient.\n - \\`recipient.phone_number\\`: The phone number of the recipient.\n - \\`tenant.id\\`: The id of the tenant.\n - \\`tenant.name\\`: The name of the tenant.\n\n You can supply any other dynamic variables by referencing them under the \\`data\\` key in the \\`data\\` parameter when triggering the workflow. You add those like \\`{{ data.variable_name }}\\`.\n\n You can also supply a list of categories to the workflow. These are used to categorize workflows for notification preferences. Categories should be supplied as lowercase strings in kebab case.\n\n Once you've created the workflow, you should ask if you should commit the changes to the environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z.string().describe(\"(string): The key of the workflow.\"),\n name: z.string().describe(\"(string): The name of the workflow.\"),\n categories: z\n .array(z.string())\n .optional()\n .describe(\"(array): The categories to add to the workflow.\"),\n subject: z.string().describe(\"(string): The subject of the email.\"),\n body: z.string().describe(\"(string): The body of the email.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const emailChannelsPage = await knockClient.channels.list();\n const emailChannels = emailChannelsPage.entries.filter(\n (channel) => channel.type === \"email\"\n );\n\n if (emailChannels.length === 0) {\n throw new Error(\"No email channels found\");\n }\n\n const workflowParams: WorkflowUpsertParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n workflow: {\n name: params.name,\n categories: params.categories ?? [],\n steps: [\n {\n type: \"channel\",\n channel_key: emailChannels[0].key,\n template: {\n settings: {\n layout_key: \"default\",\n },\n subject: params.subject,\n visual_blocks: [\n // @ts-ignore\n {\n type: \"markdown\",\n content: params.body,\n },\n ],\n },\n name: \"Email\",\n ref: \"email_1\",\n },\n ],\n },\n };\n\n const result = await knockClient.workflows.upsert(\n params.workflowKey,\n workflowParams\n );\n\n return serializeWorkflowResponse(result.workflow);\n },\n});\n\nconst createOneOffWorkflowSchedule = KnockTool({\n method: \"create_one_off_workflow_schedule\",\n name: \"Create one-off workflow schedule\",\n description: `\n Create a one-off workflow schedule for a user. Use this tool when you need to schedule the execution of a workflow for a specific user in the future, like to power a delayed notification.\n \n Schedules can accept a set of data that will be passed to the workflow trigger when it is executed. When the userId is not provided, the schedule will be created for the current user specified in the config.\n\n Examples:\n \n - In three days, send a welcome email to a user\n - In one hour, send a password reset email to a user\n - In two weeks, send a survey to a user\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to schedule.\"),\n userId: z\n .string()\n .describe(\n \"(string): The userId of the user to schedule the workflow for.\"\n ),\n scheduledAt: z\n .string()\n .describe(\n \"(string): The date and time to schedule the workflow for. Must be in ISO 8601 format.\"\n ),\n data: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): Data to pass to the workflow.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.workflows.createSchedules(params.workflowKey, {\n recipients: [params.userId ?? config.userId],\n scheduled_at: params.scheduledAt,\n data: params.data,\n });\n },\n});\n\nexport const workflows = {\n listWorkflows,\n getWorkflow,\n triggerWorkflow,\n createEmailWorkflow,\n createOneOffWorkflowSchedule,\n};\n\nexport const permissions = {\n read: [\"listWorkflows\", \"getWorkflow\"],\n manage: [\"createEmailWorkflow\", \"createOneOffWorkflowSchedule\"],\n run: [\"triggerWorkflow\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst searchDocumentation = KnockTool({\n method: \"search_documentation\",\n name: \"Search documentation\",\n description: \"Search the Knock documentation for a given query\",\n parameters: z.object({\n query: z.string().describe(\"The query to search the documentation for\"),\n }),\n execute: () => async (params) => {\n const response = await fetch(`https://docs.knock.app/api/search`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({ query: params.query }),\n });\n\n const data = await response.json();\n return data;\n },\n});\n\nexport const documentation = {\n searchDocumentation,\n};\n\nexport const permissions = {\n read: [\"searchDocumentation\"],\n};\n","import { 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\";\nimport {\n documentation,\n permissions as documentationPermissions,\n} from \"./documentation.js\";\n\nexport const tools = {\n channels,\n commits,\n documentation,\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 ...documentation,\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 documentation: documentationPermissions,\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":";AACA,SAAS,SAAS;AA8ClB,IAAM,YAAY,CAAC,SACjB,KACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,KAAK,IAAI;AAEP,IAAM,YAAY,CACvB,SACc;AACd,QAAM,EAAE,SAAS,GAAG,WAAW,IAAI;AACnC,QAAM,aAAa,WAAW,aAC1B,WAAW,aACX,EAAE,OAAO,CAAC,CAAC;AAEf,QAAM,gBA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AAAA,MACA,MAAM,KAAK,UAAU,EAAE,OAAO,OAAO,MAAM,CAAC;AAAA,IAC9C,CAAC;AAED,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,WAAO;AAAA,EACT;AACF,CAAC;AAEM,IAAM,gBAAgB;AAAA,EAC3B;AACF;AAEO,IAAMC,gBAAc;AAAA,EACzB,MAAM,CAAC,qBAAqB;AAC9B;;;ACLO,IAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,WAAW;AAAA,EACtB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEO,IAAM,kBAAkB;AAAA,EAC7B,UAAU;AAAA,EACV,SAASC;AAAA,EACT,eAAeA;AAAA,EACf,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":["z","z","permissions","z","permissions","permissions","z","z","permissions","z","z","permissions","z","z","permissions","z","permissions","z","z","permissions","z","tools","category","z","messages","permissions","z","z","permissions","z","z","permissions","permissions"]}
@@ -0,0 +1,29 @@
1
+ // src/lib/knock-client.ts
2
+ import { Knock } from "@knocklabs/node";
3
+ import KnockMgmt from "@knocklabs/mgmt";
4
+ var serviceTokensToApiClients = {};
5
+ var createKnockClient = (config) => {
6
+ const client = new KnockMgmt({
7
+ serviceToken: config.serviceToken
8
+ });
9
+ return Object.assign(client, {
10
+ publicApi: async (environmentSlug) => {
11
+ const environment = environmentSlug ?? config.environment ?? "development";
12
+ if (serviceTokensToApiClients?.[config.serviceToken]?.[environment]) {
13
+ return serviceTokensToApiClients[config.serviceToken][environment];
14
+ }
15
+ const { api_key } = await client.apiKeys.exchange({ environment });
16
+ const knock = new Knock(api_key);
17
+ if (!serviceTokensToApiClients[config.serviceToken]) {
18
+ serviceTokensToApiClients[config.serviceToken] = {};
19
+ }
20
+ serviceTokensToApiClients[config.serviceToken][environment] = knock;
21
+ return knock;
22
+ }
23
+ });
24
+ };
25
+
26
+ export {
27
+ createKnockClient
28
+ };
29
+ //# sourceMappingURL=chunk-CXOB4H3U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/knock-client.ts"],"sourcesContent":["import { Knock } from \"@knocklabs/node\";\nimport KnockMgmt from \"@knocklabs/mgmt\";\nimport { Config } from \"../types.js\";\n\nconst serviceTokensToApiClients: Record<string, Record<string, Knock>> = {};\n\ntype KnockClient = ReturnType<typeof createKnockClient>;\n\nconst createKnockClient = (config: Config) => {\n const client = new KnockMgmt({\n serviceToken: config.serviceToken,\n });\n\n return Object.assign(client, {\n publicApi: async (environmentSlug?: string): Promise<Knock> => {\n const environment =\n environmentSlug ?? config.environment ?? \"development\";\n\n // If the client already exists for this service token and environment, return it\n if (serviceTokensToApiClients?.[config.serviceToken]?.[environment]) {\n return serviceTokensToApiClients[config.serviceToken][environment];\n }\n\n // Otherwise, fetch a public API key for this service token and environment\n const { api_key } = await client.apiKeys.exchange({ environment });\n\n // Create a new Knock client with the public API key\n const knock = new Knock(api_key);\n\n // Store the client in the cache\n if (!serviceTokensToApiClients[config.serviceToken]) {\n serviceTokensToApiClients[config.serviceToken] = {};\n }\n\n serviceTokensToApiClients[config.serviceToken][environment] = knock;\n\n return knock;\n },\n });\n};\n\nexport { createKnockClient, type KnockClient };\n"],"mappings":";AAAA,SAAS,aAAa;AACtB,OAAO,eAAe;AAGtB,IAAM,4BAAmE,CAAC;AAI1E,IAAM,oBAAoB,CAAC,WAAmB;AAC5C,QAAM,SAAS,IAAI,UAAU;AAAA,IAC3B,cAAc,OAAO;AAAA,EACvB,CAAC;AAED,SAAO,OAAO,OAAO,QAAQ;AAAA,IAC3B,WAAW,OAAO,oBAA6C;AAC7D,YAAM,cACJ,mBAAmB,OAAO,eAAe;AAG3C,UAAI,4BAA4B,OAAO,YAAY,IAAI,WAAW,GAAG;AACnE,eAAO,0BAA0B,OAAO,YAAY,EAAE,WAAW;AAAA,MACnE;AAGA,YAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,QAAQ,SAAS,EAAE,YAAY,CAAC;AAGjE,YAAM,QAAQ,IAAI,MAAM,OAAO;AAG/B,UAAI,CAAC,0BAA0B,OAAO,YAAY,GAAG;AACnD,kCAA0B,OAAO,YAAY,IAAI,CAAC;AAAA,MACpD;AAEA,gCAA0B,OAAO,YAAY,EAAE,WAAW,IAAI;AAE9D,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  allTools
3
- } from "./chunk-3NU2K26A.js";
3
+ } from "./chunk-3CUTEODM.js";
4
4
 
5
5
  // src/modelcontextprotocol/adapter.ts
6
6
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
7
7
  import { z } from "zod";
8
8
  var KnockMcpServer = class extends McpServer {
9
9
  constructor(knockClient, config, tools) {
10
- super({ name: "Knock", version: "0.1.6" });
10
+ super({ name: "Knock", version: "0.1.7" });
11
11
  tools.forEach((tool) => {
12
12
  const toolParams = tool.parameters ?? z.object({});
13
13
  this.tool(
@@ -36,4 +36,4 @@ var createKnockMcpServer = async (params) => {
36
36
  export {
37
37
  createKnockMcpServer
38
38
  };
39
- //# sourceMappingURL=chunk-GGZXDBNR.js.map
39
+ //# sourceMappingURL=chunk-SADGJJQS.js.map
@@ -1,5 +1,5 @@
1
1
  import { ZodObject } from 'zod';
2
- import { C as Config } from '../types-BePFw9M2.js';
2
+ import { C as Config } from '../types-DmmGlWVt.js';
3
3
  import { Knock } from '@knocklabs/node';
4
4
  import KnockMgmt from '@knocklabs/mgmt';
5
5
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createKnockMcpServer
3
- } from "../chunk-GGZXDBNR.js";
4
- import "../chunk-3NU2K26A.js";
3
+ } from "../chunk-SADGJJQS.js";
4
+ import "../chunk-3CUTEODM.js";
5
5
  export {
6
6
  createKnockMcpServer
7
7
  };
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- createKnockClient,
4
- filterTools
5
- } from "../chunk-NOMOK3LZ.js";
6
2
  import {
7
3
  createKnockMcpServer
8
- } from "../chunk-GGZXDBNR.js";
4
+ } from "../chunk-SADGJJQS.js";
5
+ import {
6
+ createKnockClient
7
+ } from "../chunk-CXOB4H3U.js";
9
8
  import {
9
+ filterTools,
10
10
  tools
11
- } from "../chunk-3NU2K26A.js";
11
+ } from "../chunk-3CUTEODM.js";
12
12
 
13
13
  // src/modelcontextprotocol/local-server.ts
14
14
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -1,5 +1,5 @@
1
1
  import { ChatCompletionTool, ChatCompletionMessageToolCall, ChatCompletionToolMessageParam } from 'openai/resources.mjs';
2
- import { T as ToolkitConfig, a as ToolCategory } from '../types-BePFw9M2.js';
2
+ import { T as ToolkitConfig, a as ToolCategory } from '../types-DmmGlWVt.js';
3
3
 
4
4
  declare const createKnockToolkit: (config: ToolkitConfig) => {
5
5
  /**
@@ -1,8 +1,9 @@
1
1
  import {
2
- createKnockClient,
2
+ createKnockClient
3
+ } from "../chunk-CXOB4H3U.js";
4
+ import {
3
5
  getToolsByPermissionsInCategories
4
- } from "../chunk-NOMOK3LZ.js";
5
- import "../chunk-3NU2K26A.js";
6
+ } from "../chunk-3CUTEODM.js";
6
7
 
7
8
  // src/openai/tool-converter.ts
8
9
  import { z } from "zod";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/openai/tool-converter.ts","../../src/openai/index.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../lib/knock-tool.js\";\nimport { ChatCompletionTool } from \"openai/resources.mjs\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\n\n/**\n * Convert a KnockTool to a ChatCompletionTool, ready to be used with the OpenAI API.\n *\n * @param knockTool - The KnockTool to convert\n * @returns The converted ChatCompletionTool\n */\nexport function knockToolToChatCompletionTool(\n knockTool: KnockTool\n): ChatCompletionTool {\n return {\n type: \"function\",\n function: {\n // NOTE: We use the method here as the function name as it's machine readable.\n name: knockTool.method,\n description: knockTool.description,\n parameters: zodToJsonSchema(knockTool.parameters ?? z.object({})),\n },\n };\n}\n","import {\n ChatCompletionTool,\n ChatCompletionMessageToolCall,\n ChatCompletionToolMessageParam,\n} from \"openai/resources.mjs\";\nimport { ToolCategory, ToolkitConfig } from \"../types.js\";\nimport { getToolsByPermissionsInCategories } from \"../lib/utils.js\";\nimport { createKnockClient } from \"../lib/knock-client.js\";\nimport { knockToolToChatCompletionTool } from \"./tool-converter.js\";\nimport { KnockTool } from \"../lib/knock-tool.js\";\n\nconst createKnockToolkit = (config: ToolkitConfig) => {\n const knockClient = createKnockClient(config);\n const allowedToolsByCategory = getToolsByPermissionsInCategories(config);\n\n const toolsByMethod = Object.values(allowedToolsByCategory)\n .flat()\n .reduce(\n (acc, tool) => ({ ...acc, [tool.method]: tool }),\n {} as Record<string, KnockTool>\n );\n\n return {\n /**\n * Get all tools as a flat list.\n *\n * @returns An array of all tools\n */\n getAllTools: (): ChatCompletionTool[] =>\n Object.values(toolsByMethod).map((t) => knockToolToChatCompletionTool(t)),\n\n /**\n * Get all tools for a specific category.\n *\n * @param category - The category of too ls to get\n * @returns An array of tools for the given category\n */\n getTools: (category: ToolCategory): ChatCompletionTool[] =>\n allowedToolsByCategory[category].map((t) =>\n knockToolToChatCompletionTool(t)\n ),\n\n /**\n * Get a map of all tools by method name.\n *\n * @returns A map of all tools by method name\n */\n getToolMap: () =>\n Object.entries(toolsByMethod).reduce(\n (acc, [method, tool]) => {\n acc[method] = knockToolToChatCompletionTool(tool);\n return acc;\n },\n {} as Record<string, ChatCompletionTool>\n ),\n /**\n * Handle a tool call from the OpenAI API. Call this to invoke the tool.\n *\n * @param toolCall - The tool call to handle\n * @returns The result of the tool call\n */\n handleToolCall: async (toolCall: ChatCompletionMessageToolCall) => {\n const tool = toolsByMethod[toolCall.function.name];\n\n if (!tool) {\n throw new Error(`Tool ${toolCall.function.name} not found`);\n }\n\n const result = await tool.bindExecute(\n knockClient,\n config\n )(toolCall.function.arguments);\n\n return {\n role: \"tool\",\n tool_call_id: toolCall.id,\n content: result,\n } as ChatCompletionToolMessageParam;\n },\n };\n};\n\nexport { createKnockToolkit };\n"],"mappings":";;;;;;;AAAA,SAAS,SAAS;AAGlB,SAAS,uBAAuB;AAQzB,SAAS,8BACd,WACoB;AACpB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA;AAAA,MAER,MAAM,UAAU;AAAA,MAChB,aAAa,UAAU;AAAA,MACvB,YAAY,gBAAgB,UAAU,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,IAClE;AAAA,EACF;AACF;;;ACZA,IAAM,qBAAqB,CAAC,WAA0B;AACpD,QAAM,cAAc,kBAAkB,MAAM;AAC5C,QAAM,yBAAyB,kCAAkC,MAAM;AAEvE,QAAM,gBAAgB,OAAO,OAAO,sBAAsB,EACvD,KAAK,EACL;AAAA,IACC,CAAC,KAAK,UAAU,EAAE,GAAG,KAAK,CAAC,KAAK,MAAM,GAAG,KAAK;AAAA,IAC9C,CAAC;AAAA,EACH;AAEF,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAML,aAAa,MACX,OAAO,OAAO,aAAa,EAAE,IAAI,CAAC,MAAM,8BAA8B,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ1E,UAAU,CAAC,aACT,uBAAuB,QAAQ,EAAE;AAAA,MAAI,CAAC,MACpC,8BAA8B,CAAC;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOF,YAAY,MACV,OAAO,QAAQ,aAAa,EAAE;AAAA,MAC5B,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM;AACvB,YAAI,MAAM,IAAI,8BAA8B,IAAI;AAChD,eAAO;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOF,gBAAgB,OAAO,aAA4C;AACjE,YAAM,OAAO,cAAc,SAAS,SAAS,IAAI;AAEjD,UAAI,CAAC,MAAM;AACT,cAAM,IAAI,MAAM,QAAQ,SAAS,SAAS,IAAI,YAAY;AAAA,MAC5D;AAEA,YAAM,SAAS,MAAM,KAAK;AAAA,QACxB;AAAA,QACA;AAAA,MACF,EAAE,SAAS,SAAS,SAAS;AAE7B,aAAO;AAAA,QACL,MAAM;AAAA,QACN,cAAc,SAAS;AAAA,QACvB,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/openai/tool-converter.ts","../../src/openai/index.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../lib/knock-tool.js\";\nimport { ChatCompletionTool } from \"openai/resources.mjs\";\nimport { zodToJsonSchema } from \"zod-to-json-schema\";\n\n/**\n * Convert a KnockTool to a ChatCompletionTool, ready to be used with the OpenAI API.\n *\n * @param knockTool - The KnockTool to convert\n * @returns The converted ChatCompletionTool\n */\nexport function knockToolToChatCompletionTool(\n knockTool: KnockTool\n): ChatCompletionTool {\n return {\n type: \"function\",\n function: {\n // NOTE: We use the method here as the function name as it's machine readable.\n name: knockTool.method,\n description: knockTool.description,\n parameters: zodToJsonSchema(knockTool.parameters ?? z.object({})),\n },\n };\n}\n","import {\n ChatCompletionTool,\n ChatCompletionMessageToolCall,\n ChatCompletionToolMessageParam,\n} from \"openai/resources.mjs\";\nimport { ToolCategory, ToolkitConfig } from \"../types.js\";\nimport { getToolsByPermissionsInCategories } from \"../lib/utils.js\";\nimport { createKnockClient } from \"../lib/knock-client.js\";\nimport { knockToolToChatCompletionTool } from \"./tool-converter.js\";\nimport { KnockTool } from \"../lib/knock-tool.js\";\n\nconst createKnockToolkit = (config: ToolkitConfig) => {\n const knockClient = createKnockClient(config);\n const allowedToolsByCategory = getToolsByPermissionsInCategories(config);\n\n const toolsByMethod = Object.values(allowedToolsByCategory)\n .flat()\n .reduce(\n (acc, tool) => ({ ...acc, [tool.method]: tool }),\n {} as Record<string, KnockTool>\n );\n\n return {\n /**\n * Get all tools as a flat list.\n *\n * @returns An array of all tools\n */\n getAllTools: (): ChatCompletionTool[] =>\n Object.values(toolsByMethod).map((t) => knockToolToChatCompletionTool(t)),\n\n /**\n * Get all tools for a specific category.\n *\n * @param category - The category of too ls to get\n * @returns An array of tools for the given category\n */\n getTools: (category: ToolCategory): ChatCompletionTool[] =>\n allowedToolsByCategory[category].map((t) =>\n knockToolToChatCompletionTool(t)\n ),\n\n /**\n * Get a map of all tools by method name.\n *\n * @returns A map of all tools by method name\n */\n getToolMap: () =>\n Object.entries(toolsByMethod).reduce(\n (acc, [method, tool]) => {\n acc[method] = knockToolToChatCompletionTool(tool);\n return acc;\n },\n {} as Record<string, ChatCompletionTool>\n ),\n /**\n * Handle a tool call from the OpenAI API. Call this to invoke the tool.\n *\n * @param toolCall - The tool call to handle\n * @returns The result of the tool call\n */\n handleToolCall: async (toolCall: ChatCompletionMessageToolCall) => {\n const tool = toolsByMethod[toolCall.function.name];\n\n if (!tool) {\n throw new Error(`Tool ${toolCall.function.name} not found`);\n }\n\n const result = await tool.bindExecute(\n knockClient,\n config\n )(toolCall.function.arguments);\n\n return {\n role: \"tool\",\n tool_call_id: toolCall.id,\n content: result,\n } as ChatCompletionToolMessageParam;\n },\n };\n};\n\nexport { createKnockToolkit };\n"],"mappings":";;;;;;;;AAAA,SAAS,SAAS;AAG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,QACxB;AAAA,QACA;AAAA,MACF,EAAE,SAAS,SAAS,SAAS;AAE7B,aAAO;AAAA,QACL,MAAM;AAAA,QACN,cAAc,SAAS;AAAA,QACvB,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -6,6 +6,9 @@ declare const toolPermissions: {
6
6
  read: string[];
7
7
  manage: string[];
8
8
  };
9
+ documentation: {
10
+ read: string[];
11
+ };
9
12
  emailLayouts: {
10
13
  read: string[];
11
14
  };
@@ -59,6 +62,11 @@ interface Config {
59
62
  * the `development` environment.
60
63
  */
61
64
  environment?: string | undefined;
65
+ /**
66
+ * Whether to hide user data from LLM responses. When true, the LLM will not have access to user
67
+ * data and only the ID will be returned. Defaults to `false`.
68
+ */
69
+ hideUserData?: boolean | undefined;
62
70
  }
63
71
  type TransformPermissions<T> = {
64
72
  [K in keyof T]?: {
@@ -66,6 +74,9 @@ type TransformPermissions<T> = {
66
74
  };
67
75
  };
68
76
  interface ToolkitConfig extends Config {
77
+ /**
78
+ * The permissions to use for the toolkit.
79
+ */
69
80
  permissions: TransformPermissions<typeof toolPermissions>;
70
81
  }
71
82
  type ToolCategory = keyof typeof toolPermissions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/agent-toolkit",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "A toolkit for working with Knock in Agent workflows.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/knock-tool.ts","../src/lib/tools/channels.ts","../src/lib/tools/commits.ts","../src/lib/tools/email-layouts.ts","../src/lib/tools/environments.ts","../src/lib/tools/messages.ts","../src/lib/tools/message-types.ts","../src/lib/tools/objects.ts","../src/lib/tools/partials.ts","../src/lib/tools/tenants.ts","../src/lib/tools/users.ts","../src/lib/tools/workflows.ts","../src/lib/tools/index.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 { Channel } from \"@knocklabs/mgmt/resources/channels.js\";\n\nconst listChannels = KnockTool({\n method: \"list_channels\",\n name: \"List channels\",\n description: `\n Returns a list of all of the channels configured in the account. Each channel returns information about the type of channel it is (email, sms, push, etc), and the provider that's used to power the channel. Channels can be used across all environments.\n\n Use this tool when you need to know about the channels configured in the Knock account, like when configuring a workflow.\n `,\n execute: (knockClient) => async (params) => {\n const allChannels: Channel[] = [];\n for await (const channel of knockClient.channels.list()) {\n allChannels.push(channel);\n }\n return allChannels;\n },\n});\n\nexport const channels = {\n listChannels,\n};\n\nexport const permissions = {\n read: [\"listChannels\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listCommits = KnockTool({\n method: \"list_commits\",\n name: \"List commits\",\n description: `\n Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list commits for. Defaults to `development`.\"\n ),\n promoted: z\n .boolean()\n .describe(\n \"(boolean): Whether to only return promoted commits. Defaults to `false`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.list({\n environment: params.environment ?? config.environment ?? \"development\",\n promoted: params.promoted ?? false,\n });\n },\n});\n\nconst commitAllChanges = KnockTool({\n method: \"commit_all_changes\",\n name: \"Commit all changes\",\n description: `\n Commit all pending changes. This can only be used in the development environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to commit all changes to. Defaults to `development`.\"\n ),\n message: z\n .string()\n .optional()\n .describe(\"(string): The message to include in the commit.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.commitAll({\n environment: params.environment ?? config.environment ?? \"development\",\n commit_message: params.message,\n });\n },\n});\n\nconst promoteAllCommits = KnockTool({\n method: \"promote_all_commits\",\n name: \"Promote all commits\",\n description: `\n Promote all commits to the next environment. Use this tool when you are asked to deploy all changes.\n `,\n parameters: z.object({\n toEnvironment: z\n .string()\n .describe(\"(string): The environment to promote all commits to.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.put(\"/v1/commits/promote\", {\n body: { to_environment: params.toEnvironment },\n });\n },\n});\n\nexport const commits = {\n listCommits,\n commitAllChanges,\n promoteAllCommits,\n};\n\nexport const permissions = {\n read: [\"listCommits\"],\n manage: [\"commitAllChanges\", \"promoteAllCommits\"],\n};\n","import { 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 .optional()\n .describe(\n \"(string): The environment to list email layouts for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allEmailLayouts: 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","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","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 environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the message from. Defaults to `development`.\"\n ),\n messageId: z\n .string()\n .describe(\"(string): The messageId of the message to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.messages.getContent(params.messageId);\n },\n});\n\nexport const messages = {\n getMessageContent,\n};\n\nexport const permissions = {\n read: [\"getMessageContent\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { MessageType } from \"@knocklabs/mgmt/resources/message-types.js\";\n\nconst listMessageTypes = KnockTool({\n method: \"list_message_types\",\n name: \"List message types\",\n description:\n \"List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list message types for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allMessageTypes: MessageType[] = [];\n for await (const messageType of knockClient.messageTypes.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allMessageTypes.push(messageType);\n }\n return allMessageTypes;\n },\n});\n\nconst createOrUpdateMessageType = KnockTool({\n method: \"create_or_update_message_type\",\n name: \"Create or update message type\",\n description: `\n Create or update a message type. A message type is a schema that defines fields available to an editor within Knock. Message types always have at least one variant, that MUST be named \"default\".\n \n Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.\n\n The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named \"text\" will be rendered as {{ text }}.\n\n <example>\n <description>\n Create a new message type for a banner component that has a text and an action URL.\n </description>\n <input>\n {\n \"messageTypeKey\": \"banner\",\n \"name\": \"Banner\",\n \"description\": \"A banner component that has a text and an action URL.\",\n \"preview\": \"<div>{{ text }}</div>\",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"text\",\n \"type\": \"text\",\n \"label\": \"Text\",\n \"settings\": {\n \"max_length\": 100,\n },\n },\n {\n \"key\": \"action_url\",\n \"type\": \"text\",\n \"label\": \"Action URL\",\n \"settings\": {\n \"placeholder\": \"https://example.com\",\n },\n }\n ]\n }\n ]\n }\n </input>\n </example>\n <example>\n <description>\n Create a message type for a card component that has an icon type, title, body, and a single action button.\n </description>\n <input>\n {\n \"messageTypeKey\": \"card\",\n \"name\": \"Card\",\n \"description\": \"A single-action card component.\",\n \"preview\": \"\n <div>\n <h2>{{ title }}</h2>\n <p>{{ body }}</p>\n <button>Action</button>\n </div>\n \",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"icon_type\",\n \"type\": \"select\",\n \"label\": \"Icon type\",\n \"settings\": {\n \"options\": [\n {\n \"value\": \"warning\",\n \"label\": \"Warning\",\n },\n ]\n },\n },\n {\n \"key\": \"description\",\n \"type\": \"markdown\",\n \"label\": \"Description\",\n },\n {\n \"key\": \"action_button\",\n \"type\": \"button\",\n \"label\": \"Action button\",\n },\n ]\n }\n ]\n }\n </input>\n </example>\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the message type in. Defaults to `development`.\"\n ),\n messageTypeKey: z\n .string()\n .describe(\"(string): The key of the message type to create or update.\"),\n name: z.string().describe(\"(string): The name of the message type.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the message type.\"),\n preview: z\n .string()\n .optional()\n .describe(\n \"(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants.\"\n ),\n variants: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the variant.\"),\n name: z.string().describe(\"(string): The name of the variant.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the variant.\"),\n fields: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the field.\"),\n type: z\n .string()\n .describe(\n \"(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`, `image`.\"\n ),\n label: z.string().describe(\"(string): The label of the field.\"),\n settings: z\n .object({})\n .optional()\n .describe(\"(object): The settings of the field.\"),\n })\n )\n .describe(\"(array): The fields of the variant.\"),\n })\n )\n .describe(\"(array): The variants of the message type.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.messageTypes.upsert(params.messageTypeKey, {\n message_type: {\n name: params.name,\n variants: params.variants,\n description: params.description ?? \"\",\n preview: params.preview ?? \"<div></div>\",\n },\n environment: params.environment ?? config.environment ?? \"development\",\n });\n },\n});\n\nexport const messageTypes = {\n listMessageTypes,\n createOrUpdateMessageType,\n};\n\nexport const permissions = {\n read: [\"listMessageTypes\"],\n manage: [\"createOrUpdateMessageType\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listObjects = KnockTool({\n method: \"list_objects\",\n name: \"List objects\",\n description:\n \"List all objects in a single collection. Objects are used to model custom collections in Knock that are NOT users or tenants. Use this tool when you need to return a paginated list of objects in a single collection.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list objects from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to list objects from.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.list(params.collection);\n },\n});\n\nconst getObject = KnockTool({\n method: \"get_object\",\n name: \"Get object\",\n description:\n \"Get an object wihin a collection. Returns information about the object including any custom properties. Use this tool when you need to retrieve an object to understand it's properties.\",\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to get the object from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to get the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.get(params.collection, params.objectId);\n },\n});\n\nconst createOrUpdateObject = KnockTool({\n method: \"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 environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the object in. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to create or update the object in.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to create or update.\"),\n properties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): The properties to set on the object.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.set(\n params.collection,\n params.objectId,\n params.properties\n );\n },\n});\n\nconst subscribeUsersToObject = KnockTool({\n method: \"subscribe_users_to_object\",\n name: \"Subscribe users to object\",\n description: `\n Subscribe a list of users to an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to subscribe one or more users to an object where you will then trigger workflows for those lists of users to send notifications to.\n\n Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to subscribe the user to. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to subscribe the user to.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to subscribe the user to.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.addSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nconst unsubscribeUsersFromObject = KnockTool({\n method: \"unsubscribe_users_from_object\",\n name: \"Unsubscribe users from object\",\n description: `Unsubscribe a list of users from an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to unsubscribe one or more users from an object where you will then trigger workflows for those lists of users to send notifications to.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to unsubscribe the user from. Defaults to `development`.\"\n ),\n collection: z\n .string()\n .describe(\"(string): The collection to unsubscribe the user from.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to unsubscribe the user from.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to unsubscribe from the object.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.objects.deleteSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nexport const objects = {\n listObjects,\n getObject,\n createOrUpdateObject,\n subscribeUsersToObject,\n unsubscribeUsersFromObject,\n};\n\nexport const permissions = {\n read: [\"listObjects\", \"getObject\"],\n manage: [\n \"createOrUpdateObject\",\n \"subscribeUsersToObject\",\n \"unsubscribeUsersFromObject\",\n ],\n};\n","import { 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: `\n List all partials within the environment given. Partials provide common building blocks for notification templates. Returns information about the partial, including the name and the key. \n Use this tool when you need to know the available partials for the environment, like when building a notification template and wanting to use a partial to build the template.`,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list partials for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allPartials: 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","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 environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the tenant from. Defaults to `development`.\"\n ),\n tenantId: z\n .string()\n .describe(\"(string): The ID of the tenant to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.get(params.tenantId);\n },\n});\n\nconst listTenants = KnockTool({\n method: \"list_tenants\",\n name: \"List tenants\",\n description: `\n Retrieves a list of tenants. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object. \n \n Use this tool when you need to list all tenants in an environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the tenants from. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.list();\n },\n});\n\nconst 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 environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to set the tenant in. Defaults to `development`.\"\n ),\n tenantId: z.string().describe(\"(string): The ID of the tenant to update.\"),\n name: z.string().optional().describe(\"(string): The name of the tenant.\"),\n properties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): The properties to set on the tenant.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n return await publicClient.tenants.set(params.tenantId, {\n name: params.name,\n ...params.properties,\n });\n },\n});\n\nexport const tenants = {\n getTenant,\n listTenants,\n setTenant,\n};\n\nexport const permissions = {\n read: [\"getTenant\", \"listTenants\"],\n manage: [\"setTenant\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getUser = KnockTool({\n method: \"get_user\",\n name: \"Get user\",\n description: `\n Retrieves the complete user object for the given userId, including email, name, phone number, and any custom properties. Use this tool when you need to retrieve a user's complete profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to retrieve.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.users.get(params.userId ?? config.userId);\n },\n});\n\nconst createOrUpdateUser = KnockTool({\n method: \"create_or_update_user\",\n name: \"Create or update user\",\n description: `\n Creates a new user if they don't exist, or updates the user object for the given userId, including email, name, phone number, and any custom properties.\n \n Use this tool when you need to update a user's profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create or update the user in. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to update.\"),\n email: z\n .string()\n .optional()\n .describe(\"(string): The email of the User to update.\"),\n name: z\n .string()\n .optional()\n .describe(\"(string): The name of the User to update.\"),\n phoneNumber: z\n .string()\n .optional()\n .describe(\"(string): The phone number of the User to update.\"),\n customProperties: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): A dictionary of custom properties to update for the User.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.users.identify(params.userId ?? config.userId, {\n email: params.email,\n name: params.name,\n phone_number: params.phoneNumber,\n ...(params.customProperties ?? {}),\n });\n },\n});\n\nconst getUserPreferences = KnockTool({\n method: \"get_user_preferences\",\n name: \"Get user preferences\",\n description: `\n Retrieves the user's notification preferences for the given userId.\n\n If the userId is not provided, it will use the userId from the config. \n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user preferences from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\n \"(string): The userId of the User to retrieve Preferences for.\"\n ),\n preferenceSetId: z\n .string()\n .optional()\n .describe(\n \"(string): The preferenceSetId of the User to retrieve preferences for. Defaults to `default`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: params.preferenceSetId ?? \"default\",\n }\n );\n },\n});\n\nconst setUserPreferences = KnockTool({\n method: \"set_user_preferences\",\n name: \"Set user preferences\",\n description: `\n Overwrites the user's notification preferences for the given userId. Allows setting per-workflow, per-category, or per-channel notification preferences. Use this tool when you are asked to update a user's notification preferences.\n\n If the userId is not provided, it will use the userId from the config.\n\n Instructions:\n\n - You must ALWAYS provide a full preference set to this tool.\n - When setting per-workflow preferences, the key in the object should be the workflow key.\n - Workflow and category preferences should always have channel types underneath.\n - The channel types available to you are: email, sms, push, chat, and in_app_feed.\n - To turn OFF a preference, you must set it to false.\n - To turn ON a preference, you must set it to true.\n\n <examples>\n <example>\n <description>\n Update the user's preferences to turn off email notifications for the \"welcome\" workflow.\n </description>\n <input>\n {\n \"workflows\": {\n \"welcome\": {\n \"channel_types\": {\n \"email\": false\n }\n }\n }\n }\n </example>\n </examples>\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to set the user preferences in. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to update preferences for.\"),\n workflows: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The workflows to update where the key is the workflow key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n categories: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The categories to update where the key is the category key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n channel_types: z\n .record(z.string(), z.boolean())\n .optional()\n .describe(\n \"(object): The channel types to update where the key is the channel type, and the value of the object is a boolean value.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const existingPreferences = await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: \"default\",\n }\n );\n\n const updatedPreferences = {\n ...existingPreferences,\n workflows: {\n ...existingPreferences.workflows,\n ...params.workflows,\n },\n categories: {\n ...existingPreferences.categories,\n ...params.categories,\n },\n channel_types: {\n ...existingPreferences.channel_types,\n ...params.channel_types,\n },\n };\n\n return await publicClient.users.setPreferences(\n params.userId ?? config.userId,\n updatedPreferences\n );\n },\n});\n\nconst getUserMessages = KnockTool({\n method: \"get_user_messages\",\n name: \"Get user messages\",\n description: `\n Retrieves the messages that this user has received from the service. Use this tool when you need information about the notifications that the user has received, including if the message has been read, seen, or interacted with. This will return a list of messages across all of the channels.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to retrieve the user messages from. Defaults to `development`.\"\n ),\n userId: z\n .string()\n .optional()\n .describe(\"(string): The userId of the User to retrieve messages for.\"),\n workflowRunId: z\n .string()\n .optional()\n .describe(\n \"(string): The workflowRunId of the User to retrieve. Use this when you want to retrieve messages sent from a workflow trigger.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.users.getMessages(\n params.userId ?? config.userId,\n {\n workflow_run_id: params.workflowRunId,\n }\n );\n },\n});\n\nexport const users = {\n getUser,\n createOrUpdateUser,\n getUserPreferences,\n setUserPreferences,\n getUserMessages,\n};\n\nexport const permissions = {\n read: [\"getUser\", \"getUserMessages\", \"getUserPreferences\"],\n manage: [\"createOrUpdateUser\", \"setUserPreferences\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport {\n Workflow,\n WorkflowUpsertParams,\n} from \"@knocklabs/mgmt/resources/index.js\";\n\nconst listWorkflows = KnockTool({\n method: \"list_workflows\",\n name: \"List workflows\",\n description: `\n List all workflows available for the given environment. Returns structural information about the workflows, including the key, name, description, and categories. Will also return the steps that make up the workflow. \n\n Use this tool when you need to understand which workflows are available to be called. \n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to list workflows for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allWorkflows: Workflow[] = [];\n const listParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n };\n\n for await (const workflow of knockClient.workflows.list(listParams)) {\n allWorkflows.push(workflow);\n }\n return allWorkflows;\n },\n});\n\nconst triggerWorkflow = KnockTool({\n method: \"trigger_workflow\",\n name: \"Trigger workflow\",\n description: `\n Trigger a workflow for one or more recipients, which may produce one or more messages for each recipient depending on the workflow's steps.\n\n Use this tool when you need to trigger a workflow to send a notification across the channels configured for the workflow. The workflow must be committed in the environment for you to trigger it.\n\n When recipients aren't provided, the workflow will be triggered for the current user specified in the config.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to trigger the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to trigger.\"),\n recipients: z\n .array(z.string())\n .optional()\n .describe(\n \"(array): The recipients to trigger the workflow for. This is an array of user IDs.\"\n ),\n data: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): Data to pass to the workflow.\"),\n tenant: z\n .record(z.string(), z.any())\n .optional()\n .describe(\n \"(object): The tenant to trigger the workflow for. Must contain an id if being sent.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n const result = await publicClient.workflows.trigger(params.workflowKey, {\n recipients: params.recipients ?? [config.userId] ?? [],\n data: params.data,\n tenant: params.tenant ?? config.tenantId,\n });\n\n return result.workflow_run_id;\n },\n});\n\nconst createEmailWorkflow = KnockTool({\n method: \"create_email_workflow\",\n name: \"Create email workflow\",\n description: `\n Creates a simple email workflow with a single step that sends an email to the recipient. Use this tool when you need to need to create an email notification, and you don't need to specify any additional steps. You can only create workflows in the development environment.\n\n The content of the email you supply should ONLY ever be in markdown format for simplicity. You can supply dynamic variables to the subject and body of the email using the liquid template language.\n\n When writing markdown, be sure to use headings (##) to separate sections of the email. Use an informal writing style, and avoid using complex language.\n\n The following variables are available to use in the email subject and body:\n\n - \\`recipient.name\\`: The name of the recipient.\n - \\`recipient.email\\`: The email of the recipient.\n - \\`recipient.phone_number\\`: The phone number of the recipient.\n - \\`tenant.id\\`: The id of the tenant.\n - \\`tenant.name\\`: The name of the tenant.\n\n You can supply any other dynamic variables by referencing them under the \\`data\\` key in the \\`data\\` parameter when triggering the workflow. You add those like \\`{{ data.variable_name }}\\`.\n\n You can also supply a list of categories to the workflow. These are used to categorize workflows for notification preferences. Categories should be supplied as lowercase strings in kebab case.\n\n Once you've created the workflow, you should ask if you should commit the changes to the environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z.string().describe(\"(string): The key of the workflow.\"),\n name: z.string().describe(\"(string): The name of the workflow.\"),\n categories: z\n .array(z.string())\n .optional()\n .describe(\"(array): The categories to add to the workflow.\"),\n subject: z.string().describe(\"(string): The subject of the email.\"),\n body: z.string().describe(\"(string): The body of the email.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const emailChannelsPage = await knockClient.channels.list();\n const emailChannels = emailChannelsPage.entries.filter(\n (channel) => channel.type === \"email\"\n );\n\n if (emailChannels.length === 0) {\n throw new Error(\"No email channels found\");\n }\n\n const workflowParams: WorkflowUpsertParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n workflow: {\n name: params.name,\n categories: params.categories ?? [],\n steps: [\n {\n type: \"channel\",\n channel_key: emailChannels[0].key,\n template: {\n settings: {\n layout_key: \"default\",\n },\n subject: params.subject,\n visual_blocks: [\n // @ts-ignore\n {\n type: \"markdown\",\n content: params.body,\n },\n ],\n },\n name: \"Email\",\n ref: \"email_1\",\n },\n ],\n },\n };\n\n return await knockClient.workflows.upsert(\n params.workflowKey,\n workflowParams\n );\n },\n});\n\nconst createOneOffWorkflowSchedule = KnockTool({\n method: \"create_one_off_workflow_schedule\",\n name: \"Create one-off workflow schedule\",\n description: `\n Create a one-off workflow schedule for a user. Use this tool when you need to schedule the execution of a workflow for a specific user in the future, like to power a delayed notification.\n \n Schedules can accept a set of data that will be passed to the workflow trigger when it is executed. When the userId is not provided, the schedule will be created for the current user specified in the config.\n\n Examples:\n \n - In three days, send a welcome email to a user\n - In one hour, send a password reset email to a user\n - In two weeks, send a survey to a user\n `,\n parameters: z.object({\n environment: z\n .string()\n .optional()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to schedule.\"),\n userId: z\n .string()\n .describe(\n \"(string): The userId of the user to schedule the workflow for.\"\n ),\n scheduledAt: z\n .string()\n .describe(\n \"(string): The date and time to schedule the workflow for. Must be in ISO 8601 format.\"\n ),\n data: z\n .record(z.string(), z.any())\n .optional()\n .describe(\"(object): Data to pass to the workflow.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi(params.environment);\n\n return await publicClient.workflows.createSchedules(params.workflowKey, {\n recipients: [params.userId ?? config.userId],\n scheduled_at: params.scheduledAt,\n data: params.data,\n });\n },\n});\n\nexport const workflows = {\n listWorkflows,\n triggerWorkflow,\n createEmailWorkflow,\n createOneOffWorkflowSchedule,\n};\n\nexport const permissions = {\n read: [\"listWorkflows\"],\n manage: [\"createEmailWorkflow\", \"createOneOffWorkflowSchedule\"],\n run: [\"triggerWorkflow\"],\n};\n","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":";AACA,SAAS,SAAS;AA8ClB,IAAM,YAAY,CAAC,SACjB,KACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,KAAK,IAAI;AAEP,IAAM,YAAY,C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zB;;;ACpNO,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,SAASC;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":["z","z","permissions","z","permissions","permissions","z","z","permissions","z","z","permissions","z","z","permissions","z","permissions","z","z","permissions","z","z","permissions","z","z","permissions","permissions"]}
@@ -1,91 +0,0 @@
1
- import {
2
- toolPermissions,
3
- tools
4
- } from "./chunk-3NU2K26A.js";
5
-
6
- // src/lib/utils.ts
7
- function filterTools(tools2, pattern) {
8
- if (!pattern) {
9
- throw new Error("No pattern provided");
10
- }
11
- if (pattern === "*") {
12
- return Object.values(tools2).flatMap((category2) => Object.values(category2));
13
- }
14
- const [category, tool] = pattern.split(".");
15
- if (category === "*" && tool === "*") {
16
- return Object.values(tools2).flatMap((category2) => Object.values(category2));
17
- }
18
- if (category && !tools2[category]) {
19
- throw new Error(`Tool category ${category} not found`);
20
- }
21
- if (category && tool === "*") {
22
- return Object.values(tools2[category]);
23
- }
24
- if (category && tool && !tools2[category][tool]) {
25
- throw new Error(`Tool ${pattern} not found`);
26
- }
27
- return [tools2[category][tool]];
28
- }
29
- function getToolsWithPermissions(category, categoryPermissions) {
30
- const toolsInCategory = tools[category];
31
- const toolPermissionsInCategory = toolPermissions[category];
32
- return Object.entries(categoryPermissions).reduce(
33
- (acc, [permissionType, hasPermission]) => {
34
- if (hasPermission) {
35
- return acc.concat(
36
- toolPermissionsInCategory[permissionType].map(
37
- (toolName) => toolsInCategory[toolName]
38
- )
39
- );
40
- }
41
- return acc;
42
- },
43
- []
44
- );
45
- }
46
- function getToolsByPermissionsInCategories(config) {
47
- return Object.keys(config.permissions).reduce(
48
- (acc, category) => {
49
- const categoryKey = category;
50
- const categoryPermissions = config.permissions[categoryKey];
51
- if (tools[categoryKey] && categoryPermissions) {
52
- const tools2 = getToolsWithPermissions(categoryKey, categoryPermissions);
53
- return { ...acc, [categoryKey]: tools2 };
54
- }
55
- return acc;
56
- },
57
- {}
58
- );
59
- }
60
-
61
- // src/lib/knock-client.ts
62
- import { Knock } from "@knocklabs/node";
63
- import KnockMgmt from "@knocklabs/mgmt";
64
- var serviceTokensToApiClients = {};
65
- var createKnockClient = (config) => {
66
- const client = new KnockMgmt({
67
- serviceToken: config.serviceToken
68
- });
69
- return Object.assign(client, {
70
- publicApi: async (environmentSlug) => {
71
- const environment = environmentSlug ?? config.environment ?? "development";
72
- if (serviceTokensToApiClients?.[config.serviceToken]?.[environment]) {
73
- return serviceTokensToApiClients[config.serviceToken][environment];
74
- }
75
- const { api_key } = await client.apiKeys.exchange({ environment });
76
- const knock = new Knock(api_key);
77
- if (!serviceTokensToApiClients[config.serviceToken]) {
78
- serviceTokensToApiClients[config.serviceToken] = {};
79
- }
80
- serviceTokensToApiClients[config.serviceToken][environment] = knock;
81
- return knock;
82
- }
83
- });
84
- };
85
-
86
- export {
87
- filterTools,
88
- getToolsByPermissionsInCategories,
89
- createKnockClient
90
- };
91
- //# sourceMappingURL=chunk-NOMOK3LZ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/utils.ts","../src/lib/knock-client.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","import { Knock } from \"@knocklabs/node\";\nimport KnockMgmt from \"@knocklabs/mgmt\";\nimport { Config } from \"../types.js\";\n\nconst serviceTokensToApiClients: Record<string, Record<string, Knock>> = {};\n\ntype KnockClient = ReturnType<typeof createKnockClient>;\n\nconst createKnockClient = (config: Config) => {\n const client = new KnockMgmt({\n serviceToken: config.serviceToken,\n });\n\n return Object.assign(client, {\n publicApi: async (environmentSlug?: string): Promise<Knock> => {\n const environment =\n environmentSlug ?? config.environment ?? \"development\";\n\n // If the client already exists for this service token and environment, return it\n if (serviceTokensToApiClients?.[config.serviceToken]?.[environment]) {\n return serviceTokensToApiClients[config.serviceToken][environment];\n }\n\n // Otherwise, fetch a public API key for this service token and environment\n const { api_key } = await client.apiKeys.exchange({ environment });\n\n // Create a new Knock client with the public API key\n const knock = new Knock(api_key);\n\n // Store the client in the cache\n if (!serviceTokensToApiClients[config.serviceToken]) {\n serviceTokensToApiClients[config.serviceToken] = {};\n }\n\n serviceTokensToApiClients[config.serviceToken][environment] = knock;\n\n return knock;\n },\n });\n};\n\nexport { createKnockClient, type KnockClient };\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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