@knocklabs/agent-toolkit 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-sdk/index.js +22 -1085
- package/dist/ai-sdk/index.js.map +1 -1
- package/dist/ai-sdk/tool-converter.js +3 -10
- package/dist/ai-sdk/tool-converter.js.map +1 -1
- package/dist/chunk-2CNJ4XX6.js +33 -0
- package/dist/chunk-2CNJ4XX6.js.map +1 -0
- package/dist/chunk-3LZK6RH6.js +29 -0
- package/dist/chunk-3LZK6RH6.js.map +1 -0
- package/dist/chunk-4VR65G5W.js +66 -0
- package/dist/chunk-4VR65G5W.js.map +1 -0
- package/dist/chunk-6H3BXH2Y.js +15 -0
- package/dist/chunk-6H3BXH2Y.js.map +1 -0
- package/dist/chunk-BY4KQPUO.js +39 -0
- package/dist/chunk-BY4KQPUO.js.map +1 -0
- package/dist/chunk-DSRTYV37.js +39 -0
- package/dist/chunk-DSRTYV37.js.map +1 -0
- package/dist/chunk-JTYQTWCX.js +75 -0
- package/dist/chunk-JTYQTWCX.js.map +1 -0
- package/dist/chunk-NZB2TMJW.js +92 -0
- package/dist/chunk-NZB2TMJW.js.map +1 -0
- package/dist/chunk-O6DWF42E.js +31 -0
- package/dist/chunk-O6DWF42E.js.map +1 -0
- package/dist/chunk-OD5VHBGN.js +32 -0
- package/dist/chunk-OD5VHBGN.js.map +1 -0
- package/dist/chunk-PDMA6RIB.js +19 -0
- package/dist/chunk-PDMA6RIB.js.map +1 -0
- package/dist/chunk-RYMJEH6P.js +140 -0
- package/dist/chunk-RYMJEH6P.js.map +1 -0
- package/dist/chunk-THLK376Y.js +191 -0
- package/dist/chunk-THLK376Y.js.map +1 -0
- package/dist/chunk-TLHETJRF.js +75 -0
- package/dist/chunk-TLHETJRF.js.map +1 -0
- package/dist/chunk-TOBLV65T.js +30 -0
- package/dist/chunk-TOBLV65T.js.map +1 -0
- package/dist/chunk-VJFA3ZVW.js +210 -0
- package/dist/chunk-VJFA3ZVW.js.map +1 -0
- package/dist/chunk-WB4XCCUS.js +19 -0
- package/dist/chunk-WB4XCCUS.js.map +1 -0
- package/dist/chunk-XRQWR3LY.js +184 -0
- package/dist/chunk-XRQWR3LY.js.map +1 -0
- package/dist/chunk-XUYE3AGB.js +27 -0
- package/dist/chunk-XUYE3AGB.js.map +1 -0
- package/dist/lib/knock-client.js +3 -24
- package/dist/lib/knock-client.js.map +1 -1
- package/dist/lib/knock-tool.js +3 -25
- package/dist/lib/knock-tool.js.map +1 -1
- package/dist/lib/tools/channels.js +5 -49
- package/dist/lib/tools/channels.js.map +1 -1
- package/dist/lib/tools/commits.js +5 -93
- package/dist/lib/tools/commits.js.map +1 -1
- package/dist/lib/tools/email-layouts.js +5 -55
- package/dist/lib/tools/email-layouts.js.map +1 -1
- package/dist/lib/tools/environments.js +5 -47
- package/dist/lib/tools/environments.js.map +1 -1
- package/dist/lib/tools/index.js +17 -1016
- package/dist/lib/tools/index.js.map +1 -1
- package/dist/lib/tools/message-types.js +5 -209
- package/dist/lib/tools/message-types.js.map +1 -1
- package/dist/lib/tools/messages.js +5 -50
- package/dist/lib/tools/messages.js.map +1 -1
- package/dist/lib/tools/objects.js +5 -158
- package/dist/lib/tools/objects.js.map +1 -1
- package/dist/lib/tools/partials.js +5 -55
- package/dist/lib/tools/partials.js.map +1 -1
- package/dist/lib/tools/tenants.js +5 -93
- package/dist/lib/tools/tenants.js.map +1 -1
- package/dist/lib/tools/users.js +5 -228
- package/dist/lib/tools/users.js.map +1 -1
- package/dist/lib/tools/workflows.js +5 -202
- package/dist/lib/tools/workflows.js.map +1 -1
- package/dist/lib/utils.js +18 -1071
- package/dist/lib/utils.js.map +1 -1
- package/dist/modelcontextprotocol/adapter.js +3 -22
- package/dist/modelcontextprotocol/adapter.js.map +1 -1
- package/dist/modelcontextprotocol/index.js +17 -976
- package/dist/modelcontextprotocol/index.js.map +1 -1
- package/dist/modelcontextprotocol/local-server.js +25 -1041
- package/dist/modelcontextprotocol/local-server.js.map +1 -1
- package/dist/openai/index.js +22 -1089
- package/dist/openai/index.js.map +1 -1
- package/dist/openai/tool-converter.js +3 -14
- package/dist/openai/tool-converter.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,205 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
var trimLines = (text) => text.split("\n").map((l) => l.trim()).filter(Boolean).join("\n");
|
|
7
|
-
var KnockTool = (args) => {
|
|
8
|
-
const { execute, ...restOfArgs } = args;
|
|
9
|
-
const parameters = restOfArgs.parameters ? restOfArgs.parameters : z.object({});
|
|
10
|
-
const schemaEntries = Object.entries(parameters.shape);
|
|
11
|
-
const argsStr = schemaEntries.length === 0 ? "Takes no arguments" : schemaEntries.map(([key, value]) => {
|
|
12
|
-
return `- ${key}: ${value.description || ""}`;
|
|
13
|
-
}).join("\n");
|
|
14
|
-
const fullDescription = trimLines(`
|
|
15
|
-
Tool name:
|
|
16
|
-
${args.name}
|
|
17
|
-
Description:
|
|
18
|
-
${args.description}.
|
|
19
|
-
Arguments:
|
|
20
|
-
${argsStr}
|
|
21
|
-
`);
|
|
22
|
-
return {
|
|
23
|
-
...restOfArgs,
|
|
24
|
-
parameters,
|
|
25
|
-
fullDescription,
|
|
26
|
-
bindExecute: (knockClient, config) => execute(knockClient, config)
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// src/lib/tools/workflows.ts
|
|
31
|
-
var listWorkflows = KnockTool({
|
|
32
|
-
method: "list_workflows",
|
|
33
|
-
name: "List workflows",
|
|
34
|
-
description: `
|
|
35
|
-
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.
|
|
36
|
-
|
|
37
|
-
Use this tool when you need to understand which workflows are available to be called.
|
|
38
|
-
`,
|
|
39
|
-
parameters: z2.object({
|
|
40
|
-
environment: z2.string().describe(
|
|
41
|
-
"(string): The environment to list workflows for. Defaults to `development`."
|
|
42
|
-
)
|
|
43
|
-
}),
|
|
44
|
-
execute: (knockClient, config) => async (params) => {
|
|
45
|
-
const allWorkflows = [];
|
|
46
|
-
const listParams = {
|
|
47
|
-
environment: params.environment ?? config.environment ?? "development"
|
|
48
|
-
};
|
|
49
|
-
for await (const workflow of knockClient.workflows.list(listParams)) {
|
|
50
|
-
allWorkflows.push(workflow);
|
|
51
|
-
}
|
|
52
|
-
return allWorkflows;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
var triggerWorkflow = KnockTool({
|
|
56
|
-
method: "trigger_workflow",
|
|
57
|
-
name: "Trigger workflow",
|
|
58
|
-
description: `
|
|
59
|
-
Trigger a workflow for one or more recipients.
|
|
60
|
-
|
|
61
|
-
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.
|
|
62
|
-
|
|
63
|
-
When recipients aren't provided, the workflow will be triggered for the current user specified in the config.
|
|
64
|
-
`,
|
|
65
|
-
parameters: z2.object({
|
|
66
|
-
workflowKey: z2.string().describe("(string): The key of the workflow to trigger."),
|
|
67
|
-
recipients: z2.array(z2.string()).describe("(array): The recipients to trigger the workflow for."),
|
|
68
|
-
data: z2.record(z2.string(), z2.any()).describe("(object): Data to pass to the workflow."),
|
|
69
|
-
tenant: z2.record(z2.string(), z2.any()).describe(
|
|
70
|
-
"(object): The tenant to trigger the workflow for. Must contain an id if being sent."
|
|
71
|
-
)
|
|
72
|
-
}),
|
|
73
|
-
execute: (knockClient, config) => async (params) => {
|
|
74
|
-
const publicClient = await knockClient.publicApi();
|
|
75
|
-
const result = await publicClient.workflows.trigger(params.workflowKey, {
|
|
76
|
-
recipients: params.recipients,
|
|
77
|
-
data: params.data,
|
|
78
|
-
tenant: params.tenant
|
|
79
|
-
});
|
|
80
|
-
return result.workflow_run_id;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
var createEmailWorkflow = KnockTool({
|
|
84
|
-
method: "create_email_workflow",
|
|
85
|
-
name: "Create email workflow",
|
|
86
|
-
description: `
|
|
87
|
-
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.
|
|
88
|
-
|
|
89
|
-
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.
|
|
90
|
-
|
|
91
|
-
When writing markdown, be sure to use headings (##) to separate sections of the email. Use an informal writing style, and avoid using complex language.
|
|
92
|
-
|
|
93
|
-
The following variables are available to use in the email subject and body:
|
|
94
|
-
|
|
95
|
-
- \`recipient.name\`: The name of the recipient.
|
|
96
|
-
- \`recipient.email\`: The email of the recipient.
|
|
97
|
-
- \`recipient.phone_number\`: The phone number of the recipient.
|
|
98
|
-
- \`tenant.id\`: The id of the tenant.
|
|
99
|
-
- \`tenant.name\`: The name of the tenant.
|
|
100
|
-
|
|
101
|
-
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 }}\`.
|
|
102
|
-
|
|
103
|
-
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.
|
|
104
|
-
|
|
105
|
-
Once you've created the workflow, you should ask if you should commit the changes to the environment.
|
|
106
|
-
`,
|
|
107
|
-
parameters: z2.object({
|
|
108
|
-
environment: z2.string().describe(
|
|
109
|
-
"(string): The environment to create the workflow in. Defaults to `development`."
|
|
110
|
-
),
|
|
111
|
-
workflowKey: z2.string().describe("(string): The key of the workflow."),
|
|
112
|
-
name: z2.string().describe("(string): The name of the workflow."),
|
|
113
|
-
categories: z2.array(z2.string()).describe("(array): The categories to add to the workflow."),
|
|
114
|
-
subject: z2.string().describe("(string): The subject of the email."),
|
|
115
|
-
body: z2.string().describe("(string): The body of the email.")
|
|
116
|
-
}),
|
|
117
|
-
execute: (knockClient, config) => async (params) => {
|
|
118
|
-
const emailChannelsPage = await knockClient.channels.list();
|
|
119
|
-
const emailChannels = emailChannelsPage.entries.filter(
|
|
120
|
-
(channel) => channel.type === "email"
|
|
121
|
-
);
|
|
122
|
-
if (emailChannels.length === 0) {
|
|
123
|
-
throw new Error("No email channels found");
|
|
124
|
-
}
|
|
125
|
-
const workflowParams = {
|
|
126
|
-
environment: params.environment ?? config.environment ?? "development",
|
|
127
|
-
workflow: {
|
|
128
|
-
name: params.name,
|
|
129
|
-
categories: params.categories ?? [],
|
|
130
|
-
steps: [
|
|
131
|
-
{
|
|
132
|
-
type: "channel",
|
|
133
|
-
channel_key: emailChannels[0].key,
|
|
134
|
-
template: {
|
|
135
|
-
settings: {
|
|
136
|
-
layout_key: "default"
|
|
137
|
-
},
|
|
138
|
-
subject: params.subject,
|
|
139
|
-
visual_blocks: [
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
{
|
|
142
|
-
type: "markdown",
|
|
143
|
-
content: params.body
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
},
|
|
147
|
-
name: "Email",
|
|
148
|
-
ref: "email_1"
|
|
149
|
-
}
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
return await knockClient.workflows.upsert(
|
|
154
|
-
params.workflowKey,
|
|
155
|
-
workflowParams
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
var createOneOffWorkflowSchedule = KnockTool({
|
|
160
|
-
method: "create_one_off_workflow_schedule",
|
|
161
|
-
name: "Create one-off workflow schedule",
|
|
162
|
-
description: `
|
|
163
|
-
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.
|
|
164
|
-
|
|
165
|
-
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.
|
|
166
|
-
|
|
167
|
-
Examples:
|
|
168
|
-
|
|
169
|
-
- In three days, send a welcome email to a user
|
|
170
|
-
- In one hour, send a password reset email to a user
|
|
171
|
-
- In two weeks, send a survey to a user
|
|
172
|
-
`,
|
|
173
|
-
parameters: z2.object({
|
|
174
|
-
workflowKey: z2.string().describe("(string): The key of the workflow to schedule."),
|
|
175
|
-
userId: z2.string().describe(
|
|
176
|
-
"(string): The userId of the user to schedule the workflow for."
|
|
177
|
-
),
|
|
178
|
-
scheduledAt: z2.string().describe(
|
|
179
|
-
"(string): The date and time to schedule the workflow for. Must be in ISO 8601 format."
|
|
180
|
-
),
|
|
181
|
-
data: z2.record(z2.string(), z2.any()).describe("(object): Data to pass to the workflow.")
|
|
182
|
-
}),
|
|
183
|
-
execute: (knockClient, config) => async (params) => {
|
|
184
|
-
const publicClient = await knockClient.publicApi();
|
|
185
|
-
return await publicClient.workflows.createSchedules(params.workflowKey, {
|
|
186
|
-
recipients: [params.userId ?? config.userId],
|
|
187
|
-
scheduled_at: params.scheduledAt,
|
|
188
|
-
data: params.data
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
var workflows = {
|
|
193
|
-
listWorkflows,
|
|
194
|
-
triggerWorkflow,
|
|
195
|
-
createEmailWorkflow,
|
|
196
|
-
createOneOffWorkflowSchedule
|
|
197
|
-
};
|
|
198
|
-
var permissions = {
|
|
199
|
-
read: ["listWorkflows"],
|
|
200
|
-
manage: ["createEmailWorkflow", "createOneOffWorkflowSchedule"],
|
|
201
|
-
trigger: ["triggerWorkflow"]
|
|
202
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
permissions,
|
|
3
|
+
workflows
|
|
4
|
+
} from "../../chunk-XRQWR3LY.js";
|
|
5
|
+
import "../../chunk-TOBLV65T.js";
|
|
203
6
|
export {
|
|
204
7
|
permissions,
|
|
205
8
|
workflows
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/tools/workflows.ts","../../../src/lib/knock-tool.ts"],"sourcesContent":["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 .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.\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 workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to trigger.\"),\n recipients: z\n .array(z.string())\n .describe(\"(array): The recipients to trigger the workflow for.\"),\n data: z\n .record(z.string(), z.any())\n .describe(\"(object): Data to pass to the workflow.\"),\n tenant: z\n .record(z.string(), z.any())\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();\n\n const result = await publicClient.workflows.trigger(params.workflowKey, {\n recipients: params.recipients,\n data: params.data,\n tenant: params.tenant,\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 .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 .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 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 .describe(\"(object): Data to pass to the workflow.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\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 trigger: [\"triggerWorkflow\"],\n};\n","import type { ZodObject } from \"zod\";\nimport { z } from \"zod\";\nimport { Config } from \"../types.js\";\nimport { KnockClient } from \"./knock-client.js\";\n\nexport interface KnockToolDefinition {\n /**\n * The method name of the tool. This is a machine-readable string.\n */\n method: string;\n /**\n * The name of the tool. This can be used to reference the tool in the code.\n * A descriptive LLM-readable string.\n */\n name: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, including examples where useful.\n */\n description: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, usage and input parameters.\n * Ths is intended to be used by the underlying LLM.\n */\n fullDescription: string;\n\n /**\n * The Zod schema for the input parameters of the tool\n */\n parameters?: ZodObject<any>;\n /**\n * The actual implementation of the tool.\n */\n execute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nexport interface KnockTool extends Omit<KnockToolDefinition, \"execute\"> {\n bindExecute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nconst trimLines = (text: string) =>\n text\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter(Boolean)\n .join(\"\\n\");\n\nexport const KnockTool = (\n args: Omit<KnockToolDefinition, \"fullDescription\">\n): KnockTool => {\n const { execute, ...restOfArgs } = args;\n const parameters = restOfArgs.parameters\n ? restOfArgs.parameters\n : z.object({});\n\n const schemaEntries = Object.entries(parameters.shape);\n\n const argsStr =\n schemaEntries.length === 0\n ? \"Takes no arguments\"\n : schemaEntries\n .map(([key, value]) => {\n return `- ${key}: ${(value as any).description || \"\"}`;\n })\n .join(\"\\n\");\n\n const fullDescription = trimLines(`\n Tool name:\n ${args.name}\n Description:\n ${args.description}.\n Arguments:\n ${argsStr}\n `);\n\n return {\n ...restOfArgs,\n parameters,\n fullDescription,\n bindExecute: (knockClient: KnockClient, config: Config) =>\n execute(knockClient, config),\n };\n};\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACClB,SAAS,SAAS;AA8ClB,IAAM,YAAY,CAAC,SACjB,KACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,KAAK,IAAI;AAEP,IAAM,YAAY,CACvB,SACc;AACd,QAAM,EAAE,SAAS,GAAG,WAAW,IAAI;AACnC,QAAM,aAAa,WAAW,aAC1B,WAAW,aACX,EAAE,OAAO,CAAC,CAAC;AAEf,QAAM,gBAAgB,OAAO,QAAQ,WAAW,KAAK;AAErD,QAAM,UACJ,cAAc,WAAW,IACrB,uBACA,cACG,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AACrB,WAAO,KAAK,GAAG,KAAM,MAAc,e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