@knocklabs/agent-toolkit 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/ai-sdk/index.d.ts +1 -4
  2. package/dist/ai-sdk/index.js +14 -20
  3. package/dist/ai-sdk/index.js.map +1 -1
  4. package/dist/{chunk-XUYE3AGB.js → chunk-B6DIDKFY.js} +14 -2
  5. package/dist/chunk-B6DIDKFY.js.map +1 -0
  6. package/dist/chunk-RPKDXX4O.js +1023 -0
  7. package/dist/chunk-RPKDXX4O.js.map +1 -0
  8. package/dist/{chunk-4VR65G5W.js → chunk-ZV2SOIO7.js} +29 -4
  9. package/dist/chunk-ZV2SOIO7.js.map +1 -0
  10. package/dist/modelcontextprotocol/index.d.ts +47 -6
  11. package/dist/modelcontextprotocol/index.js +2 -15
  12. package/dist/modelcontextprotocol/local-server.js +5 -20
  13. package/dist/modelcontextprotocol/local-server.js.map +1 -1
  14. package/dist/openai/index.d.ts +1 -4
  15. package/dist/openai/index.js +18 -20
  16. package/dist/openai/index.js.map +1 -1
  17. package/dist/types-DyB12-Gk.d.ts +73 -0
  18. package/package.json +2 -2
  19. package/dist/ai-sdk/tool-converter.d.ts +0 -12
  20. package/dist/ai-sdk/tool-converter.js +0 -7
  21. package/dist/ai-sdk/tool-converter.js.map +0 -1
  22. package/dist/chunk-2CNJ4XX6.js +0 -33
  23. package/dist/chunk-2CNJ4XX6.js.map +0 -1
  24. package/dist/chunk-3LZK6RH6.js +0 -29
  25. package/dist/chunk-3LZK6RH6.js.map +0 -1
  26. package/dist/chunk-4VR65G5W.js.map +0 -1
  27. package/dist/chunk-6H3BXH2Y.js +0 -15
  28. package/dist/chunk-6H3BXH2Y.js.map +0 -1
  29. package/dist/chunk-BY4KQPUO.js +0 -39
  30. package/dist/chunk-BY4KQPUO.js.map +0 -1
  31. package/dist/chunk-DSRTYV37.js +0 -39
  32. package/dist/chunk-DSRTYV37.js.map +0 -1
  33. package/dist/chunk-JTYQTWCX.js +0 -75
  34. package/dist/chunk-JTYQTWCX.js.map +0 -1
  35. package/dist/chunk-NZB2TMJW.js +0 -92
  36. package/dist/chunk-NZB2TMJW.js.map +0 -1
  37. package/dist/chunk-O6DWF42E.js +0 -31
  38. package/dist/chunk-O6DWF42E.js.map +0 -1
  39. package/dist/chunk-OD5VHBGN.js +0 -32
  40. package/dist/chunk-OD5VHBGN.js.map +0 -1
  41. package/dist/chunk-PDMA6RIB.js +0 -19
  42. package/dist/chunk-PDMA6RIB.js.map +0 -1
  43. package/dist/chunk-RYMJEH6P.js +0 -140
  44. package/dist/chunk-RYMJEH6P.js.map +0 -1
  45. package/dist/chunk-THLK376Y.js +0 -191
  46. package/dist/chunk-THLK376Y.js.map +0 -1
  47. package/dist/chunk-TLHETJRF.js +0 -75
  48. package/dist/chunk-TLHETJRF.js.map +0 -1
  49. package/dist/chunk-TOBLV65T.js +0 -30
  50. package/dist/chunk-TOBLV65T.js.map +0 -1
  51. package/dist/chunk-VJFA3ZVW.js +0 -210
  52. package/dist/chunk-VJFA3ZVW.js.map +0 -1
  53. package/dist/chunk-WB4XCCUS.js +0 -19
  54. package/dist/chunk-WB4XCCUS.js.map +0 -1
  55. package/dist/chunk-XRQWR3LY.js +0 -184
  56. package/dist/chunk-XRQWR3LY.js.map +0 -1
  57. package/dist/chunk-XUYE3AGB.js.map +0 -1
  58. package/dist/lib/knock-client.d.ts +0 -4
  59. package/dist/lib/knock-client.js +0 -7
  60. package/dist/lib/knock-client.js.map +0 -1
  61. package/dist/lib/knock-tool.d.ts +0 -4
  62. package/dist/lib/knock-tool.js +0 -7
  63. package/dist/lib/knock-tool.js.map +0 -1
  64. package/dist/lib/tools/channels.d.ts +0 -13
  65. package/dist/lib/tools/channels.js +0 -10
  66. package/dist/lib/tools/channels.js.map +0 -1
  67. package/dist/lib/tools/commits.d.ts +0 -16
  68. package/dist/lib/tools/commits.js +0 -10
  69. package/dist/lib/tools/commits.js.map +0 -1
  70. package/dist/lib/tools/email-layouts.d.ts +0 -13
  71. package/dist/lib/tools/email-layouts.js +0 -10
  72. package/dist/lib/tools/email-layouts.js.map +0 -1
  73. package/dist/lib/tools/environments.d.ts +0 -13
  74. package/dist/lib/tools/environments.js +0 -10
  75. package/dist/lib/tools/environments.js.map +0 -1
  76. package/dist/lib/tools/index.d.ts +0 -4
  77. package/dist/lib/tools/index.js +0 -23
  78. package/dist/lib/tools/index.js.map +0 -1
  79. package/dist/lib/tools/message-types.d.ts +0 -15
  80. package/dist/lib/tools/message-types.js +0 -10
  81. package/dist/lib/tools/message-types.js.map +0 -1
  82. package/dist/lib/tools/messages.d.ts +0 -13
  83. package/dist/lib/tools/messages.js +0 -10
  84. package/dist/lib/tools/messages.js.map +0 -1
  85. package/dist/lib/tools/objects.d.ts +0 -19
  86. package/dist/lib/tools/objects.js +0 -10
  87. package/dist/lib/tools/objects.js.map +0 -1
  88. package/dist/lib/tools/partials.d.ts +0 -13
  89. package/dist/lib/tools/partials.js +0 -10
  90. package/dist/lib/tools/partials.js.map +0 -1
  91. package/dist/lib/tools/tenants.d.ts +0 -16
  92. package/dist/lib/tools/tenants.js +0 -10
  93. package/dist/lib/tools/tenants.js.map +0 -1
  94. package/dist/lib/tools/users.d.ts +0 -19
  95. package/dist/lib/tools/users.js +0 -10
  96. package/dist/lib/tools/users.js.map +0 -1
  97. package/dist/lib/tools/workflows.d.ts +0 -18
  98. package/dist/lib/tools/workflows.js +0 -10
  99. package/dist/lib/tools/workflows.js.map +0 -1
  100. package/dist/lib/utils.d.ts +0 -33
  101. package/dist/lib/utils.js +0 -24
  102. package/dist/lib/utils.js.map +0 -1
  103. package/dist/modelcontextprotocol/adapter.d.ts +0 -11
  104. package/dist/modelcontextprotocol/adapter.js +0 -7
  105. package/dist/modelcontextprotocol/adapter.js.map +0 -1
  106. package/dist/openai/tool-converter.d.ts +0 -15
  107. package/dist/openai/tool-converter.js +0 -7
  108. package/dist/openai/tool-converter.js.map +0 -1
  109. package/dist/types-B-9pppCQ.d.ts +0 -199
  110. package/dist/types.d.ts +0 -4
  111. package/dist/types.js +0 -1
  112. package/dist/types.js.map +0 -1
@@ -1,191 +0,0 @@
1
- import {
2
- KnockTool
3
- } from "./chunk-TOBLV65T.js";
4
-
5
- // src/lib/tools/message-types.ts
6
- import { z } from "zod";
7
- var listMessageTypes = KnockTool({
8
- method: "list_message_types",
9
- name: "List message types",
10
- description: "List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.",
11
- parameters: z.object({
12
- environment: z.string().describe(
13
- "(string): The environment to list message types for. Defaults to `development`."
14
- )
15
- }),
16
- execute: (knockClient, config) => async (params) => {
17
- const allMessageTypes = [];
18
- for await (const messageType of knockClient.messageTypes.list({
19
- environment: params.environment ?? config.environment ?? "development"
20
- })) {
21
- allMessageTypes.push(messageType);
22
- }
23
- return allMessageTypes;
24
- }
25
- });
26
- var createOrUpdateMessageType = KnockTool({
27
- method: "create_or_update_message_type",
28
- name: "Create or update message type",
29
- description: `
30
- Create or update a message type. A message type is a schema that defines fields available to an editor within Knock. Message types always have at least one variant, that MUST be named "default".
31
-
32
- Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.
33
-
34
- The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named "text" will be rendered as {{ text }}.
35
-
36
- <example>
37
- <description>
38
- Create a new message type for a banner component that has a text and an action URL.
39
- </description>
40
- <input>
41
- {
42
- "messageTypeKey": "banner",
43
- "name": "Banner",
44
- "description": "A banner component that has a text and an action URL.",
45
- "preview": "<div>{{ text }}</div>",
46
- "variants": [
47
- {
48
- "key": "default",
49
- "name": "Default",
50
- "fields": [
51
- {
52
- "key": "text",
53
- "type": "text",
54
- "label": "Text",
55
- "settings": {
56
- "max_length": 100,
57
- },
58
- },
59
- {
60
- "key": "action_url",
61
- "type": "text",
62
- "label": "Action URL",
63
- "settings": {
64
- "placeholder": "https://example.com",
65
- },
66
- }
67
- ]
68
- }
69
- ]
70
- }
71
- </input>
72
- </example>
73
- <example>
74
- <description>
75
- Create a message type for a card component that has an icon type, title, body, and a single action button.
76
- </description>
77
- <input>
78
- {
79
- "messageTypeKey": "card",
80
- "name": "Card",
81
- "description": "A single-action card component.",
82
- "preview": "
83
- <div>
84
- <h2>{{ title }}</h2>
85
- <p>{{ body }}</p>
86
- <button>Action</button>
87
- </div>
88
- ",
89
- "variants": [
90
- {
91
- "key": "default",
92
- "name": "Default",
93
- "fields": [
94
- {
95
- "key": "icon_type",
96
- "type": "select",
97
- "label": "Icon type",
98
- "settings": {
99
- "options": [
100
- {
101
- "value": "warning",
102
- "label": "Warning",
103
- },
104
- {
105
- "value": "success",
106
- "label": "Success",
107
- },
108
- {
109
- "value": "info",
110
- "label": "Info",
111
- },
112
- {
113
- "value": "error",
114
- "label": "Error",
115
- },
116
- ]
117
- },
118
- },
119
- {
120
- "key": "title",
121
- "type": "text",
122
- "label": "Title",
123
- },
124
- {
125
- "key": "description",
126
- "type": "markdown",
127
- "label": "Description",
128
- },
129
- {
130
- "key": "action_button",
131
- "type": "button",
132
- "label": "Action button",
133
- },
134
- ]
135
- }
136
- ]
137
- }
138
- </input>
139
- </example>
140
- `,
141
- parameters: z.object({
142
- messageTypeKey: z.string().describe("(string): The key of the message type to create or update."),
143
- name: z.string().describe("(string): The name of the message type."),
144
- description: z.string().optional().describe("(string): The description of the message type."),
145
- preview: z.string().optional().describe(
146
- "(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants."
147
- ),
148
- variants: z.array(
149
- z.object({
150
- key: z.string().describe("(string): The key of the variant."),
151
- name: z.string().describe("(string): The name of the variant."),
152
- description: z.string().optional().describe("(string): The description of the variant."),
153
- fields: z.array(
154
- z.object({
155
- key: z.string().describe("(string): The key of the field."),
156
- type: z.string().describe(
157
- "(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`."
158
- ),
159
- label: z.string().describe("(string): The label of the field."),
160
- settings: z.object({}).describe("(object): The settings of the field.")
161
- })
162
- ).describe("(array): The fields of the variant.")
163
- })
164
- ).describe("(array): The variants of the message type.")
165
- }),
166
- execute: (knockClient, config) => async (params) => {
167
- return await knockClient.messageTypes.upsert(params.messageTypeKey, {
168
- message_type: {
169
- name: params.name,
170
- variants: params.variants,
171
- description: params.description ?? "",
172
- preview: params.preview ?? "<div></div>"
173
- },
174
- environment: params.environment ?? config.environment ?? "development"
175
- });
176
- }
177
- });
178
- var messageTypes = {
179
- listMessageTypes,
180
- createOrUpdateMessageType
181
- };
182
- var permissions = {
183
- read: ["listMessageTypes"],
184
- manage: ["createOrUpdateMessageType"]
185
- };
186
-
187
- export {
188
- messageTypes,
189
- permissions
190
- };
191
- //# sourceMappingURL=chunk-THLK376Y.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/message-types.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { MessageType } from \"@knocklabs/mgmt/resources/message-types.js\";\n\nconst listMessageTypes = KnockTool({\n method: \"list_message_types\",\n name: \"List message types\",\n description:\n \"List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.\",\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list message types for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allMessageTypes: MessageType[] = [];\n for await (const messageType of knockClient.messageTypes.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allMessageTypes.push(messageType);\n }\n return allMessageTypes;\n },\n});\n\nconst createOrUpdateMessageType = KnockTool({\n method: \"create_or_update_message_type\",\n name: \"Create or update message type\",\n description: `\n Create or update a message type. A message type is a schema that defines fields available to an editor within Knock. Message types always have at least one variant, that MUST be named \"default\".\n \n Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.\n\n The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named \"text\" will be rendered as {{ text }}.\n\n <example>\n <description>\n Create a new message type for a banner component that has a text and an action URL.\n </description>\n <input>\n {\n \"messageTypeKey\": \"banner\",\n \"name\": \"Banner\",\n \"description\": \"A banner component that has a text and an action URL.\",\n \"preview\": \"<div>{{ text }}</div>\",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"text\",\n \"type\": \"text\",\n \"label\": \"Text\",\n \"settings\": {\n \"max_length\": 100,\n },\n },\n {\n \"key\": \"action_url\",\n \"type\": \"text\",\n \"label\": \"Action URL\",\n \"settings\": {\n \"placeholder\": \"https://example.com\",\n },\n }\n ]\n }\n ]\n }\n </input>\n </example>\n <example>\n <description>\n Create a message type for a card component that has an icon type, title, body, and a single action button.\n </description>\n <input>\n {\n \"messageTypeKey\": \"card\",\n \"name\": \"Card\",\n \"description\": \"A single-action card component.\",\n \"preview\": \"\n <div>\n <h2>{{ title }}</h2>\n <p>{{ body }}</p>\n <button>Action</button>\n </div>\n \",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"icon_type\",\n \"type\": \"select\",\n \"label\": \"Icon type\",\n \"settings\": {\n \"options\": [\n {\n \"value\": \"warning\",\n \"label\": \"Warning\",\n },\n {\n \"value\": \"success\",\n \"label\": \"Success\",\n },\n {\n \"value\": \"info\",\n \"label\": \"Info\",\n },\n {\n \"value\": \"error\",\n \"label\": \"Error\",\n },\n ]\n },\n },\n {\n \"key\": \"title\",\n \"type\": \"text\",\n \"label\": \"Title\",\n },\n {\n \"key\": \"description\",\n \"type\": \"markdown\",\n \"label\": \"Description\",\n },\n {\n \"key\": \"action_button\",\n \"type\": \"button\",\n \"label\": \"Action button\",\n },\n ]\n }\n ]\n }\n </input>\n </example>\n `,\n parameters: z.object({\n messageTypeKey: z\n .string()\n .describe(\"(string): The key of the message type to create or update.\"),\n name: z.string().describe(\"(string): The name of the message type.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the message type.\"),\n preview: z\n .string()\n .optional()\n .describe(\n \"(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants.\"\n ),\n variants: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the variant.\"),\n name: z.string().describe(\"(string): The name of the variant.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the variant.\"),\n fields: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the field.\"),\n type: z\n .string()\n .describe(\n \"(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`.\"\n ),\n label: z.string().describe(\"(string): The label of the field.\"),\n settings: z\n .object({})\n .describe(\"(object): The settings of the field.\"),\n })\n )\n .describe(\"(array): The fields of the variant.\"),\n })\n )\n .describe(\"(array): The variants of the message type.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.messageTypes.upsert(params.messageTypeKey, {\n message_type: {\n name: params.name,\n variants: params.variants,\n description: params.description ?? \"\",\n preview: params.preview ?? \"<div></div>\",\n },\n environment: params.environment ?? config.environment ?? \"development\",\n });\n },\n});\n\nexport const messageTypes = {\n listMessageTypes,\n createOrUpdateMessageType,\n};\n\nexport const permissions = {\n read: [\"listMessageTypes\"],\n manage: [\"createOrUpdateMessageType\"],\n};\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAIlB,IAAM,mBAAmB,UAAU;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aACE;AAAA,EACF,YAAY,EAAE,OAAO;AAAA,IACnB,aAAa,EACV,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,UAAM,kBAAiC,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;AAAA,QACP,KAAK,EAAE,OAAO,EAAE,SAAS,mCAAmC;AAAA,QAC5D,MAAM,EAAE,OAAO,EAAE,SAAS,oCAAoC;AAAA,QAC9D,aAAa,EACV,OAAO,EACP,SAAS,EACT,SAAS,2CAA2C;AAAA,QACvD,QAAQ,EACL;AAAA,UACC,EAAE,OAAO;AAAA,YACP,KAAK,EAAE,OAAO,EAAE,SAAS,iCAAiC;AAAA,YAC1D,MAAM,EACH,OAAO,EACP;AAAA,cACC;AAAA,YACF;AAAA,YACF,OAAO,EAAE,OAAO,EAAE,SAAS,mCAAmC;AAAA,YAC9D,UAAU,EACP,OAAO,CAAC,CAAC,EACT,SAAS,sCAAsC;AAAA,UACpD,CAAC;AAAA,QACH,EACC,SAAS,qCAAqC;AAAA,MACnD,CAAC;AAAA,IACH,EACC,SAAS,4CAA4C;AAAA,EAC1D,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,aAAa,OAAO,OAAO,gBAAgB;AAAA,MAClE,cAAc;AAAA,QACZ,MAAM,OAAO;AAAA,QACb,UAAU,OAAO;AAAA,QACjB,aAAa,OAAO,eAAe;AAAA,QACnC,SAAS,OAAO,WAAW;AAAA,MAC7B;AAAA,MACA,aAAa,OAAO,eAAe,OAAO,eAAe;AAAA,IAC3D,CAAC;AAAA,EACH;AACF,CAAC;AAEM,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,kBAAkB;AAAA,EACzB,QAAQ,CAAC,2BAA2B;AACtC;","names":[]}
@@ -1,75 +0,0 @@
1
- import {
2
- KnockTool
3
- } from "./chunk-TOBLV65T.js";
4
-
5
- // src/lib/tools/commits.ts
6
- import { z } from "zod";
7
- var listCommits = KnockTool({
8
- method: "list_commits",
9
- name: "List commits",
10
- description: `
11
- Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.
12
- `,
13
- parameters: z.object({
14
- environment: z.string().describe(
15
- "(string): The environment to list commits for. Defaults to `development`."
16
- ),
17
- promoted: z.boolean().describe(
18
- "(boolean): Whether to only return promoted commits. Defaults to `false`."
19
- )
20
- }),
21
- execute: (knockClient, config) => async (params) => {
22
- return await knockClient.commits.list({
23
- environment: params.environment ?? config.environment ?? "development",
24
- promoted: params.promoted ?? false
25
- });
26
- }
27
- });
28
- var commitAllChanges = KnockTool({
29
- method: "commit_all_changes",
30
- name: "Commit all changes",
31
- description: `
32
- Commit all pending changes to the current environment. Use this tool when you are asked to save all changes to the current environment. This can only be used in the development environment.
33
- `,
34
- parameters: z.object({
35
- message: z.string().describe("(string): The message to include in the commit.")
36
- }),
37
- execute: (knockClient, config) => async (params) => {
38
- return await knockClient.commits.commitAll({
39
- environment: config.environment ?? "development",
40
- commit_message: params.message
41
- });
42
- }
43
- });
44
- var promoteAllCommits = KnockTool({
45
- method: "promote_all_commits",
46
- name: "Promote all commits",
47
- description: `
48
- Promote all commits to the next environment. Use this tool when you are asked to deploy all changes.
49
-
50
- When not specified, the \`toEnvironment\` will default to the environment that comes after the environment specified in the config.
51
- `,
52
- parameters: z.object({
53
- toEnvironment: z.string().describe("(string): The environment to promote all commits to.")
54
- }),
55
- execute: (knockClient, config) => async (params) => {
56
- return await knockClient.put("/v1/commits/promote", {
57
- body: { to_environment: params.toEnvironment }
58
- });
59
- }
60
- });
61
- var commits = {
62
- listCommits,
63
- commitAllChanges,
64
- promoteAllCommits
65
- };
66
- var permissions = {
67
- read: ["listCommits"],
68
- manage: ["commitAllChanges", "promoteAllCommits"]
69
- };
70
-
71
- export {
72
- commits,
73
- permissions
74
- };
75
- //# sourceMappingURL=chunk-TLHETJRF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/commits.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listCommits = KnockTool({\n method: \"list_commits\",\n name: \"List commits\",\n description: `\n Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.\n `,\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list commits for. Defaults to `development`.\"\n ),\n promoted: z\n .boolean()\n .describe(\n \"(boolean): Whether to only return promoted commits. Defaults to `false`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.list({\n environment: params.environment ?? config.environment ?? \"development\",\n promoted: params.promoted ?? false,\n });\n },\n});\n\nconst commitAllChanges = KnockTool({\n method: \"commit_all_changes\",\n name: \"Commit all changes\",\n description: `\n Commit all pending changes to the current environment. Use this tool when you are asked to save all changes to the current environment. This can only be used in the development environment.\n `,\n parameters: z.object({\n message: z\n .string()\n .describe(\"(string): The message to include in the commit.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.commitAll({\n environment: config.environment ?? \"development\",\n commit_message: params.message,\n });\n },\n});\n\nconst promoteAllCommits = KnockTool({\n method: \"promote_all_commits\",\n name: \"Promote all commits\",\n description: `\n Promote all commits to the next environment. Use this tool when you are asked to deploy all changes. \n\n When not specified, the \\`toEnvironment\\` will default to the environment that comes after the environment specified in the config.\n `,\n parameters: z.object({\n toEnvironment: z\n .string()\n .describe(\"(string): The environment to promote all commits to.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.put(\"/v1/commits/promote\", {\n body: { to_environment: params.toEnvironment },\n });\n },\n});\n\nexport const commits = {\n listCommits,\n commitAllChanges,\n promoteAllCommits,\n};\n\nexport const permissions = {\n read: [\"listCommits\"],\n manage: [\"commitAllChanges\", \"promoteAllCommits\"],\n};\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,cAAc,UAAU;AAAA,EAC5B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,aAAa,EACV,OAAO,EACP;AAAA,MACC;AAAA,IACF;AAAA,IACF,UAAU,EACP,QAAQ,EACR;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,QAAQ,KAAK;AAAA,MACpC,aAAa,OAAO,eAAe,OAAO,eAAe;AAAA,MACzD,UAAU,OAAO,YAAY;AAAA,IAC/B,CAAC;AAAA,EACH;AACF,CAAC;AAED,IAAM,mBAAmB,UAAU;AAAA,EACjC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA,EAGb,YAAY,EAAE,OAAO;AAAA,IACnB,SAAS,EACN,OAAO,EACP,SAAS,iDAAiD;AAAA,EAC/D,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,QAAQ,UAAU;AAAA,MACzC,aAAa,OAAO,eAAe;AAAA,MACnC,gBAAgB,OAAO;AAAA,IACzB,CAAC;AAAA,EACH;AACF,CAAC;AAED,IAAM,oBAAoB,UAAU;AAAA,EAClC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAY,EAAE,OAAO;AAAA,IACnB,eAAe,EACZ,OAAO,EACP,SAAS,sDAAsD;AAAA,EACpE,CAAC;AAAA,EACD,SAAS,CAAC,aAAa,WAAW,OAAO,WAAW;AAClD,WAAO,MAAM,YAAY,IAAI,uBAAuB;AAAA,MAClD,MAAM,EAAE,gBAAgB,OAAO,cAAc;AAAA,IAC/C,CAAC;AAAA,EACH;AACF,CAAC;AAEM,IAAM,UAAU;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,MAAM,CAAC,aAAa;AAAA,EACpB,QAAQ,CAAC,oBAAoB,mBAAmB;AAClD;","names":[]}
@@ -1,30 +0,0 @@
1
- // src/lib/knock-tool.ts
2
- import { z } from "zod";
3
- var trimLines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
4
- var KnockTool = (args) => {
5
- const { execute, ...restOfArgs } = args;
6
- const parameters = restOfArgs.parameters ? restOfArgs.parameters : z.object({});
7
- const schemaEntries = Object.entries(parameters.shape);
8
- const argsStr = schemaEntries.length === 0 ? "Takes no arguments" : schemaEntries.map(([key, value]) => {
9
- return `- ${key}: ${value.description || ""}`;
10
- }).join("\n");
11
- const fullDescription = trimLines(`
12
- Tool name:
13
- ${args.name}
14
- Description:
15
- ${args.description}.
16
- Arguments:
17
- ${argsStr}
18
- `);
19
- return {
20
- ...restOfArgs,
21
- parameters,
22
- fullDescription,
23
- bindExecute: (knockClient, config) => execute(knockClient, config)
24
- };
25
- };
26
-
27
- export {
28
- KnockTool
29
- };
30
- //# sourceMappingURL=chunk-TOBLV65T.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/knock-tool.ts"],"sourcesContent":["import type { ZodObject } from \"zod\";\nimport { z } from \"zod\";\nimport { Config } from \"../types.js\";\nimport { KnockClient } from \"./knock-client.js\";\n\nexport interface KnockToolDefinition {\n /**\n * The method name of the tool. This is a machine-readable string.\n */\n method: string;\n /**\n * The name of the tool. This can be used to reference the tool in the code.\n * A descriptive LLM-readable string.\n */\n name: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, including examples where useful.\n */\n description: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, usage and input parameters.\n * Ths is intended to be used by the underlying LLM.\n */\n fullDescription: string;\n\n /**\n * The Zod schema for the input parameters of the tool\n */\n parameters?: ZodObject<any>;\n /**\n * The actual implementation of the tool.\n */\n execute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nexport interface KnockTool extends Omit<KnockToolDefinition, \"execute\"> {\n bindExecute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nconst trimLines = (text: string) =>\n text\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter(Boolean)\n .join(\"\\n\");\n\nexport const KnockTool = (\n args: Omit<KnockToolDefinition, \"fullDescription\">\n): KnockTool => {\n const { execute, ...restOfArgs } = args;\n const parameters = restOfArgs.parameters\n ? restOfArgs.parameters\n : z.object({});\n\n const schemaEntries = Object.entries(parameters.shape);\n\n const argsStr =\n schemaEntries.length === 0\n ? \"Takes no arguments\"\n : schemaEntries\n .map(([key, value]) => {\n return `- ${key}: ${(value as any).description || \"\"}`;\n })\n .join(\"\\n\");\n\n const fullDescription = trimLines(`\n Tool name:\n ${args.name}\n Description:\n ${args.description}.\n Arguments:\n ${argsStr}\n `);\n\n return {\n ...restOfArgs,\n parameters,\n fullDescription,\n bindExecute: (knockClient: KnockClient, config: Config) =>\n execute(knockClient, config),\n };\n};\n"],"mappings":";AACA,SAAS,SAAS;AA8ClB,IAAM,YAAY,CAAC,SACjB,KACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,KAAK,IAAI;AAEP,IAAM,YAAY,CACvB,SACc;AACd,QAAM,EAAE,SAAS,GAAG,WAAW,IAAI;AACnC,QAAM,aAAa,WAAW,aAC1B,WAAW,aACX,EAAE,OAAO,CAAC,CAAC;AAEf,QAAM,gBAAgB,OAAO,QAAQ,WAAW,KAAK;AAErD,QAAM,UACJ,cAAc,WAAW,IACrB,uBACA,cACG,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACrB,WAAO,KAAK,GAAG,KAAM,MAAc,eAAe,EAAE;AAAA,EACtD,CAAC,EACA,KAAK,IAAI;AAElB,QAAM,kBAAkB,UAAU;AAAA;AAAA,IAEhC,KAAK,IAAI;AAAA;AAAA,IAET,KAAK,WAAW;AAAA;AAAA,IAEhB,OAAO;AAAA,GACR;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA,aAAa,CAAC,aAA0B,WACtC,QAAQ,aAAa,MAAM;AAAA,EAC/B;AACF;","names":[]}
@@ -1,210 +0,0 @@
1
- import {
2
- KnockTool
3
- } from "./chunk-TOBLV65T.js";
4
-
5
- // src/lib/tools/users.ts
6
- import { z } from "zod";
7
- var getUser = KnockTool({
8
- method: "get_user",
9
- name: "Get user",
10
- description: `
11
- 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.
12
-
13
- If the userId is not provided, it will use the userId from the config.
14
- `,
15
- parameters: z.object({
16
- userId: z.string().describe("(string): The userId of the User to retrieve.")
17
- }),
18
- execute: (knockClient, config) => async (params) => {
19
- const publicClient = await knockClient.publicApi();
20
- return await publicClient.users.get(params.userId ?? config.userId);
21
- }
22
- });
23
- var createOrUpdateUser = KnockTool({
24
- method: "create_or_update_user",
25
- name: "Create or update user",
26
- description: `
27
- 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.
28
-
29
- Use this tool when you need to update a user's profile.
30
-
31
- If the userId is not provided, it will use the userId from the config.
32
- `,
33
- parameters: z.object({
34
- userId: z.string().describe("(string): The userId of the User to update."),
35
- email: z.string().describe("(string): The email of the User to update."),
36
- name: z.string().describe("(string): The name of the User to update."),
37
- phoneNumber: z.string().describe("(string): The phone number of the User to update."),
38
- customProperties: z.record(z.string(), z.any()).describe(
39
- "(object): A dictionary of custom properties to update for the User."
40
- )
41
- }),
42
- execute: (knockClient, config) => async (params) => {
43
- const publicClient = await knockClient.publicApi();
44
- return await publicClient.users.identify(params.userId, {
45
- email: params.email,
46
- name: params.name,
47
- phone_number: params.phoneNumber,
48
- ...params.customProperties ?? {}
49
- });
50
- }
51
- });
52
- var deleteUser = KnockTool({
53
- method: "delete_user",
54
- name: "Delete user",
55
- description: `
56
- Deletes a user. Use this tool when you've been asked to remove a user from the system.
57
- `,
58
- parameters: z.object({
59
- userId: z.string().describe("(string): The userId of the User to delete.")
60
- }),
61
- execute: (knockClient, config) => async (params) => {
62
- const publicClient = await knockClient.publicApi();
63
- await publicClient.users.delete(params.userId);
64
- return { success: true };
65
- }
66
- });
67
- var getUserPreferences = KnockTool({
68
- method: "get_user_preferences",
69
- name: "Get user preferences",
70
- description: `
71
- Retrieves the user's notification preferences for the given userId.
72
-
73
- If the userId is not provided, it will use the userId from the config.
74
- `,
75
- parameters: z.object({
76
- userId: z.string().describe(
77
- "(string): The userId of the User to retrieve Preferences for."
78
- ),
79
- preferenceSetId: z.string().describe(
80
- "(string): The preferenceSetId of the User to retrieve preferences for. Defaults to `default`."
81
- )
82
- }),
83
- execute: (knockClient, config) => async (params) => {
84
- const publicClient = await knockClient.publicApi();
85
- return await publicClient.users.getPreferences(
86
- params.userId ?? config.userId,
87
- {
88
- preferenceSet: params.preferenceSetId ?? "default"
89
- }
90
- );
91
- }
92
- });
93
- var setUserPreferences = KnockTool({
94
- method: "set_user_preferences",
95
- name: "Set user preferences",
96
- description: `
97
- 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.
98
-
99
- If the userId is not provided, it will use the userId from the config.
100
-
101
- Instructions:
102
-
103
- - You must ALWAYS provide a full preference set to this tool.
104
- - When setting per-workflow preferences, the key in the object should be the workflow key.
105
- - Workflow and category preferences should always have channel types underneath.
106
- - The channel types available to you are: email, sms, push, chat, and in_app_feed.
107
- - To turn OFF a preference, you must set it to false.
108
- - To turn ON a preference, you must set it to true.
109
-
110
- <examples>
111
- <example>
112
- <description>
113
- Update the user's preferences to turn off email notifications for the "welcome" workflow.
114
- </description>
115
- <input>
116
- {
117
- "workflows": {
118
- "welcome": {
119
- "channel_types": {
120
- "email": false
121
- }
122
- }
123
- }
124
- }
125
- </example>
126
- </examples>
127
- `,
128
- parameters: z.object({
129
- userId: z.string().describe("(string): The userId of the User to update preferences for."),
130
- workflows: z.record(z.string(), z.any()).describe(
131
- "(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."
132
- ),
133
- categories: z.record(z.string(), z.any()).describe(
134
- "(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."
135
- ),
136
- channel_types: z.record(z.string(), z.boolean()).describe(
137
- "(object): The channel types to update where the key is the channel type, and the value of the object is a boolean value."
138
- )
139
- }),
140
- execute: (knockClient, config) => async (params) => {
141
- const publicClient = await knockClient.publicApi();
142
- const existingPreferences = await publicClient.users.getPreferences(
143
- params.userId ?? config.userId,
144
- {
145
- preferenceSet: "default"
146
- }
147
- );
148
- const updatedPreferences = {
149
- ...existingPreferences,
150
- workflows: {
151
- ...existingPreferences.workflows,
152
- ...params.workflows
153
- },
154
- categories: {
155
- ...existingPreferences.categories,
156
- ...params.categories
157
- },
158
- channel_types: {
159
- ...existingPreferences.channel_types,
160
- ...params.channel_types
161
- }
162
- };
163
- return await publicClient.users.setPreferences(
164
- params.userId ?? config.userId,
165
- updatedPreferences
166
- );
167
- }
168
- });
169
- var getUserMessages = KnockTool({
170
- method: "get_user_messages",
171
- name: "Get user messages",
172
- description: `
173
- 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.
174
-
175
- If the userId is not provided, it will use the userId from the config.
176
- `,
177
- parameters: z.object({
178
- userId: z.string().describe("(string): The userId of the User to retrieve messages for."),
179
- workflowRunId: z.string().describe(
180
- "(string): The workflowRunId of the User to retrieve. Use this when you want to retrieve messages sent from a workflow trigger."
181
- )
182
- }),
183
- execute: (knockClient, config) => async (params) => {
184
- const publicClient = await knockClient.publicApi();
185
- return await publicClient.users.getMessages(
186
- params.userId ?? config.userId,
187
- {
188
- workflow_run_id: params.workflowRunId
189
- }
190
- );
191
- }
192
- });
193
- var users = {
194
- getUser,
195
- deleteUser,
196
- createOrUpdateUser,
197
- getUserPreferences,
198
- setUserPreferences,
199
- getUserMessages
200
- };
201
- var permissions = {
202
- read: ["getUser", "getUserPreferences", "getUserMessages"],
203
- manage: ["createOrUpdateUser", "deleteUser", "setUserPreferences"]
204
- };
205
-
206
- export {
207
- users,
208
- permissions
209
- };
210
- //# sourceMappingURL=chunk-VJFA3ZVW.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/tools/users.ts"],"sourcesContent":["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 userId: z\n .string()\n .describe(\"(string): The userId of the User to retrieve.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\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 userId: z.string().describe(\"(string): The userId of the User to update.\"),\n email: z.string().describe(\"(string): The email of the User to update.\"),\n name: z.string().describe(\"(string): The name of the User to update.\"),\n phoneNumber: z\n .string()\n .describe(\"(string): The phone number of the User to update.\"),\n customProperties: z\n .record(z.string(), z.any())\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();\n\n return await publicClient.users.identify(params.userId, {\n email: params.email,\n name: params.name,\n phone_number: params.phoneNumber,\n ...(params.customProperties ?? {}),\n });\n },\n});\n\nconst deleteUser = KnockTool({\n method: \"delete_user\",\n name: \"Delete user\",\n description: `\n Deletes a user. Use this tool when you've been asked to remove a user from the system.\n `,\n parameters: z.object({\n userId: z.string().describe(\"(string): The userId of the User to delete.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n await publicClient.users.delete(params.userId);\n return { success: true };\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 userId: z\n .string()\n .describe(\n \"(string): The userId of the User to retrieve Preferences for.\"\n ),\n preferenceSetId: z\n .string()\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();\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 userId: z\n .string()\n .describe(\"(string): The userId of the User to update preferences for.\"),\n workflows: z\n .record(z.string(), z.any())\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 .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 .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();\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 userId: z\n .string()\n .describe(\"(string): The userId of the User to retrieve messages for.\"),\n workflowRunId: z\n .string()\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();\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 deleteUser,\n createOrUpdateUser,\n getUserPreferences,\n setUserPreferences,\n getUserMessages,\n};\n\nexport const permissions = {\n read: [\"getUser\", \"getUserPreferences\", \"getUserMessages\"],\n manage: [\"createOrUpdateUser\", \"deleteUser\", \"setUserPreferences\"],\n};\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAGlB,IAAM,UAAU,UAAU;AAAA,EACxB,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA,EAKb,YAAY,EAAE,OAAO;AAAA,IACnB,QAAQ,EACL,OAAO,EACP,SAAS,+C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AQ,CAAC,sBAAsB,cAAc,oBAAoB;AACnE;","names":[]}
@@ -1,19 +0,0 @@
1
- // src/openai/tool-converter.ts
2
- import { z } from "zod";
3
- import { zodToJsonSchema } from "zod-to-json-schema";
4
- function knockToolToChatCompletionTool(knockTool) {
5
- return {
6
- type: "function",
7
- function: {
8
- // NOTE: We use the method here as the function name as it's machine readable.
9
- name: knockTool.method,
10
- description: knockTool.description,
11
- parameters: zodToJsonSchema(knockTool.parameters ?? z.object({}))
12
- }
13
- };
14
- }
15
-
16
- export {
17
- knockToolToChatCompletionTool
18
- };
19
- //# sourceMappingURL=chunk-WB4XCCUS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/openai/tool-converter.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"],"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;","names":[]}