@knocklabs/agent-toolkit 0.1.14 → 0.2.0
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/README.md +42 -0
- package/dist/ai-sdk/index.js +1 -1
- package/dist/{chunk-RMUYOYLN.js → chunk-QG5UJT76.js} +185 -63
- package/dist/chunk-QG5UJT76.js.map +1 -0
- package/dist/{chunk-GWRZ4NRX.js → chunk-ZUE3BSAZ.js} +3 -3
- package/dist/{chunk-GWRZ4NRX.js.map → chunk-ZUE3BSAZ.js.map} +1 -1
- package/dist/langchain/index.js +2 -2
- package/dist/langchain/index.js.map +1 -1
- package/dist/mastra/index.d.ts +18 -0
- package/dist/mastra/index.js +74 -0
- package/dist/mastra/index.js.map +1 -0
- package/dist/modelcontextprotocol/index.js +2 -2
- package/dist/modelcontextprotocol/local-server.js +7 -4
- package/dist/modelcontextprotocol/local-server.js.map +1 -1
- package/dist/openai/index.js +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +7 -2
- package/dist/chunk-RMUYOYLN.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
- [AI SDK](#ai-sdk)
|
|
13
13
|
- [OpenAI](#openai)
|
|
14
14
|
- [Langchain](#langchain)
|
|
15
|
+
- [Mastra](#mastra)
|
|
15
16
|
|
|
16
17
|
## Getting started
|
|
17
18
|
|
|
@@ -227,3 +228,44 @@ export async function POST(req: Request) {
|
|
|
227
228
|
return LangChainAdapter.toDataStreamResponse(stream);
|
|
228
229
|
}
|
|
229
230
|
```
|
|
231
|
+
|
|
232
|
+
### Mastra
|
|
233
|
+
|
|
234
|
+
The agent toolkit provides a `createKnockToolkit` under the `/mastra` path for easily integrating into the Mastra framework and returning tools ready for use.
|
|
235
|
+
|
|
236
|
+
1. Install the package:
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
npm install @knocklabs/agent-toolkit
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
2. Import the `createKnockToolkit` helper, configure it, and use it in your LLM calling:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
246
|
+
import { Agent } from "@mastra/core/agent";
|
|
247
|
+
import { Memory } from "@mastra/memory";
|
|
248
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
249
|
+
import { createKnockToolkit } from "@knocklabs/agent-toolkit/mastra";
|
|
250
|
+
|
|
251
|
+
const toolkit = await createKnockToolkit({
|
|
252
|
+
serviceToken: "knock_st_",
|
|
253
|
+
permissions: {
|
|
254
|
+
// (optional but recommended): Set the permissions of the tools to expose
|
|
255
|
+
workflows: { read: true, run: true, manage: true },
|
|
256
|
+
},
|
|
257
|
+
userId: "10",
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
export const weatherAgent = new Agent({
|
|
261
|
+
name: "Weather Agent",
|
|
262
|
+
instructions: `You are a helpful weather assistant that provides accurate weather information.`,
|
|
263
|
+
model: anthropic("claude-3-5-sonnet-20241022"),
|
|
264
|
+
tools: toolkit.getAllTools(),
|
|
265
|
+
memory: new Memory({
|
|
266
|
+
storage: new LibSQLStore({
|
|
267
|
+
url: "file:../mastra.db", // path is relative to the .mastra/output directory
|
|
268
|
+
}),
|
|
269
|
+
}),
|
|
270
|
+
});
|
|
271
|
+
```
|
package/dist/ai-sdk/index.js
CHANGED
|
@@ -156,7 +156,9 @@ import { z as z4 } from "zod";
|
|
|
156
156
|
function serializeEmailLayoutResponse(emailLayout) {
|
|
157
157
|
return {
|
|
158
158
|
key: emailLayout.key,
|
|
159
|
-
name: emailLayout.name
|
|
159
|
+
name: emailLayout.name,
|
|
160
|
+
htmlContent: emailLayout.html_layout,
|
|
161
|
+
textContent: emailLayout.text_layout
|
|
160
162
|
};
|
|
161
163
|
}
|
|
162
164
|
var listEmailLayouts = KnockTool({
|
|
@@ -180,11 +182,45 @@ var listEmailLayouts = KnockTool({
|
|
|
180
182
|
return allEmailLayouts;
|
|
181
183
|
}
|
|
182
184
|
});
|
|
185
|
+
var createOrUpdateEmailLayout = KnockTool({
|
|
186
|
+
method: "upsert_email_layout",
|
|
187
|
+
name: "Create or update email layout",
|
|
188
|
+
description: `Create or update a new email layout within the environment given. Use this tool when you need to define shared pieces of content across multiple email templates, like a header/footer. The email layout will be used to render the email template.
|
|
189
|
+
|
|
190
|
+
Here are the rules for creating an email layout:
|
|
191
|
+
|
|
192
|
+
- Every email layout must have a \`{{ content }}\` tag. This is where the content of the email will be injected.
|
|
193
|
+
- You must set both an HTML and text version of the email layout.
|
|
194
|
+
- CSS should be included in the HTML version of the email layout under <style> tags.
|
|
195
|
+
`,
|
|
196
|
+
parameters: z4.object({
|
|
197
|
+
environment: z4.string().optional().describe(
|
|
198
|
+
"(string): The environment to create or update the email layout for. Defaults to `development`."
|
|
199
|
+
),
|
|
200
|
+
key: z4.string().describe("(string): The key of the email layout to create or update."),
|
|
201
|
+
name: z4.string().describe("(string): The name of the email layout."),
|
|
202
|
+
htmlContent: z4.string().describe("(string): The HTML content of the email layout."),
|
|
203
|
+
textContent: z4.string().describe("(string): The text content of the email layout.")
|
|
204
|
+
}),
|
|
205
|
+
execute: (knockClient, config) => async (params) => {
|
|
206
|
+
const response = await knockClient.emailLayouts.upsert(params.key, {
|
|
207
|
+
environment: params.environment ?? config.environment ?? "development",
|
|
208
|
+
email_layout: {
|
|
209
|
+
name: params.name,
|
|
210
|
+
html_layout: params.htmlContent,
|
|
211
|
+
text_layout: params.textContent
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
return serializeEmailLayoutResponse(response.email_layout);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
183
217
|
var emailLayouts = {
|
|
184
|
-
listEmailLayouts
|
|
218
|
+
listEmailLayouts,
|
|
219
|
+
createOrUpdateEmailLayout
|
|
185
220
|
};
|
|
186
221
|
var permissions4 = {
|
|
187
|
-
read: ["listEmailLayouts"]
|
|
222
|
+
read: ["listEmailLayouts"],
|
|
223
|
+
manage: ["createOrUpdateEmailLayout"]
|
|
188
224
|
};
|
|
189
225
|
|
|
190
226
|
// src/lib/tools/environments.ts
|
|
@@ -245,7 +281,7 @@ var listMessageTypes = KnockTool({
|
|
|
245
281
|
}
|
|
246
282
|
});
|
|
247
283
|
var createOrUpdateMessageType = KnockTool({
|
|
248
|
-
method: "
|
|
284
|
+
method: "upsert_message_type",
|
|
249
285
|
name: "Create or update message type",
|
|
250
286
|
description: `
|
|
251
287
|
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". Use this tool when you need to create a new message type, or update an existing message type.
|
|
@@ -401,7 +437,7 @@ var getObject = KnockTool({
|
|
|
401
437
|
}
|
|
402
438
|
});
|
|
403
439
|
var createOrUpdateObject = KnockTool({
|
|
404
|
-
method: "
|
|
440
|
+
method: "upsert_object",
|
|
405
441
|
name: "Create or update object",
|
|
406
442
|
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.
|
|
407
443
|
|
|
@@ -640,9 +676,9 @@ var listTenants = KnockTool({
|
|
|
640
676
|
return await publicClient.tenants.list();
|
|
641
677
|
}
|
|
642
678
|
});
|
|
643
|
-
var
|
|
644
|
-
method: "
|
|
645
|
-
name: "
|
|
679
|
+
var createOrUpdateTenant = KnockTool({
|
|
680
|
+
method: "upsert_tenant",
|
|
681
|
+
name: "Create or update tenant",
|
|
646
682
|
description: `
|
|
647
683
|
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.
|
|
648
684
|
|
|
@@ -667,11 +703,11 @@ var setTenant = KnockTool({
|
|
|
667
703
|
var tenants = {
|
|
668
704
|
getTenant,
|
|
669
705
|
listTenants,
|
|
670
|
-
|
|
706
|
+
createOrUpdateTenant
|
|
671
707
|
};
|
|
672
708
|
var permissions10 = {
|
|
673
709
|
read: ["getTenant", "listTenants"],
|
|
674
|
-
manage: ["
|
|
710
|
+
manage: ["createOrUpdateTenant"]
|
|
675
711
|
};
|
|
676
712
|
|
|
677
713
|
// src/lib/tools/users.ts
|
|
@@ -851,7 +887,7 @@ var getUser = KnockTool({
|
|
|
851
887
|
}
|
|
852
888
|
});
|
|
853
889
|
var createOrUpdateUser = KnockTool({
|
|
854
|
-
method: "
|
|
890
|
+
method: "upsert_user",
|
|
855
891
|
name: "Create or update user",
|
|
856
892
|
description: `
|
|
857
893
|
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.
|
|
@@ -1044,11 +1080,18 @@ function generateStepRef(stepType) {
|
|
|
1044
1080
|
return `${stepType}_${randomString}`;
|
|
1045
1081
|
}
|
|
1046
1082
|
async function updateWorkflowWithStep(knockClient, workflow2, step, environment) {
|
|
1083
|
+
let workflowSteps = workflow2.steps;
|
|
1084
|
+
const existingStepIdx = workflow2.steps.findIndex((s) => s.ref === step.ref);
|
|
1085
|
+
if (existingStepIdx !== -1) {
|
|
1086
|
+
workflowSteps[existingStepIdx] = step;
|
|
1087
|
+
} else {
|
|
1088
|
+
workflowSteps.push(step);
|
|
1089
|
+
}
|
|
1047
1090
|
const workflowParams = {
|
|
1048
1091
|
environment,
|
|
1049
1092
|
workflow: {
|
|
1050
1093
|
...workflow2,
|
|
1051
|
-
steps:
|
|
1094
|
+
steps: workflowSteps
|
|
1052
1095
|
}
|
|
1053
1096
|
};
|
|
1054
1097
|
const result = await knockClient.workflows.upsert(
|
|
@@ -1059,7 +1102,9 @@ async function updateWorkflowWithStep(knockClient, workflow2, step, environment)
|
|
|
1059
1102
|
}
|
|
1060
1103
|
var SHARED_PROMPTS = {
|
|
1061
1104
|
workflow: `
|
|
1062
|
-
To use this tool, you MUST first create a workflow using the \`createWorkflow\` tool, or get an existing workflow using the \`getWorkflow\` tool.
|
|
1105
|
+
To use this tool, you MUST first create a workflow using the \`createWorkflow\` tool, or get an existing workflow using the \`getWorkflow\` tool.
|
|
1106
|
+
|
|
1107
|
+
If you are updating an existing step, you can pass the \`stepRef\` parameter to the tool. If you do not pass the \`stepRef\` parameter, a new step will be created and added to the end of the workflow's steps array. You should ONLY pass the \`stepRef\` parameter if you are updating an existing step.
|
|
1063
1108
|
`,
|
|
1064
1109
|
liquid: `
|
|
1065
1110
|
## Personalization
|
|
@@ -1067,7 +1112,7 @@ var SHARED_PROMPTS = {
|
|
|
1067
1112
|
If you need to include personalization, you can use liquid to include dynamic content in the email and the subject line.
|
|
1068
1113
|
The following variables are always available to use in liquid:
|
|
1069
1114
|
|
|
1070
|
-
- \`recipient.id\`: The ID of the recipient.
|
|
1115
|
+
- \`recipient.id\`: The ID of the recipient.
|
|
1071
1116
|
- \`recipient.name\`: The name of the recipient.
|
|
1072
1117
|
- \`recipient.email\`: The email of the recipient.
|
|
1073
1118
|
- \`recipient.phone_number\`: The phone number of the recipient.
|
|
@@ -1077,8 +1122,8 @@ var SHARED_PROMPTS = {
|
|
|
1077
1122
|
<example>
|
|
1078
1123
|
# Hello, {{ recipient.name }}
|
|
1079
1124
|
|
|
1080
|
-
This is a dynamic message:
|
|
1081
|
-
|
|
1125
|
+
This is a dynamic message:
|
|
1126
|
+
|
|
1082
1127
|
> {{ data.message }}
|
|
1083
1128
|
</example>
|
|
1084
1129
|
|
|
@@ -1091,17 +1136,56 @@ var SHARED_PROMPTS = {
|
|
|
1091
1136
|
</example>
|
|
1092
1137
|
`
|
|
1093
1138
|
};
|
|
1094
|
-
var
|
|
1095
|
-
|
|
1096
|
-
|
|
1139
|
+
var contentBlockSchema = z13.union([
|
|
1140
|
+
z13.object({
|
|
1141
|
+
type: z13.literal("markdown"),
|
|
1142
|
+
content: z13.string().describe("(string): The markdown content of the block.")
|
|
1143
|
+
}),
|
|
1144
|
+
z13.object({
|
|
1145
|
+
type: z13.literal("html"),
|
|
1146
|
+
content: z13.string().describe("(string): The HTML content of the block.")
|
|
1147
|
+
}),
|
|
1148
|
+
z13.object({
|
|
1149
|
+
type: z13.literal("image"),
|
|
1150
|
+
url: z13.string().describe("(string): The URL of the image.")
|
|
1151
|
+
}),
|
|
1152
|
+
z13.object({
|
|
1153
|
+
type: z13.literal("button_set"),
|
|
1154
|
+
buttons: z13.array(
|
|
1155
|
+
z13.object({
|
|
1156
|
+
label: z13.string().describe("(string): The label of the button."),
|
|
1157
|
+
action: z13.string().describe("(string): The action of the button."),
|
|
1158
|
+
variant: z13.enum(["solid", "outline"]).default("solid").describe(
|
|
1159
|
+
"(enum): The variant of the button. Defaults to `solid`."
|
|
1160
|
+
)
|
|
1161
|
+
})
|
|
1162
|
+
).describe("(array): The buttons for the button set.")
|
|
1163
|
+
}),
|
|
1164
|
+
z13.object({
|
|
1165
|
+
type: z13.literal("divider")
|
|
1166
|
+
}),
|
|
1167
|
+
z13.object({
|
|
1168
|
+
type: z13.literal("partial"),
|
|
1169
|
+
key: z13.string().describe("(string): The key of the partial to use."),
|
|
1170
|
+
name: z13.string().describe("(string): The name of the partial."),
|
|
1171
|
+
attrs: z13.record(z13.string(), z13.string()).describe(
|
|
1172
|
+
"(object): The attributes for the partial. ALWAYS supply an empty object when you don't know which params are required."
|
|
1173
|
+
)
|
|
1174
|
+
})
|
|
1175
|
+
]);
|
|
1176
|
+
var createOrUpdateEmailStepInWorkflow = KnockTool({
|
|
1177
|
+
method: "upsert_workflow_email_step",
|
|
1178
|
+
name: "Create or update email step in workflow",
|
|
1097
1179
|
description: `
|
|
1098
|
-
Creates an email step in a workflow. Use this tool when you're asked to create an email notification and you need to specify the content of the email.
|
|
1180
|
+
Creates or updates an email step in a workflow. Use this tool when you're asked to create an email notification and you need to specify the content of the email.
|
|
1099
1181
|
|
|
1100
1182
|
${SHARED_PROMPTS.workflow}
|
|
1101
1183
|
|
|
1184
|
+
When you're asked to create an email step, you can either set the HTML content directly or use blocks to build the email. If you're asked to set the HTML content directly, you can use the \`htmlContent\` parameter. We prefer to use blocks.
|
|
1185
|
+
|
|
1102
1186
|
## Blocks
|
|
1103
1187
|
|
|
1104
|
-
The content of the email is supplied as an array of "blocks". The simplest block is a "markdown" block, which supports content in a markdown format. That should always be your default block type.
|
|
1188
|
+
The content of the email is supplied as an array of "blocks". The simplest block is a "markdown" block, which supports content in a markdown format. That should always be your default block type.
|
|
1105
1189
|
|
|
1106
1190
|
The following block types are supported:
|
|
1107
1191
|
|
|
@@ -1148,7 +1232,7 @@ Hello, {{ recipient.name }}."
|
|
|
1148
1232
|
}
|
|
1149
1233
|
</example>
|
|
1150
1234
|
|
|
1151
|
-
### HTML
|
|
1235
|
+
### HTML
|
|
1152
1236
|
|
|
1153
1237
|
The \`html\` block supports raw HTML content. This should be used sparingly, and only when you need to include custom HTML content that markdown doesn't support. When using the \`html\` block, you must supply a \`content\` key. HTML content can include liquid personalization.
|
|
1154
1238
|
|
|
@@ -1196,7 +1280,16 @@ Hello, {{ recipient.name }}."
|
|
|
1196
1280
|
`,
|
|
1197
1281
|
parameters: z13.object({
|
|
1198
1282
|
workflowKey: z13.string().describe("(string): The key of the workflow to add the step to."),
|
|
1199
|
-
|
|
1283
|
+
stepRef: z13.string().optional().describe(
|
|
1284
|
+
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1285
|
+
),
|
|
1286
|
+
htmlContent: z13.string().describe(
|
|
1287
|
+
"(string): The HTML content of the email template. Use this when not setting blocks."
|
|
1288
|
+
),
|
|
1289
|
+
blocks: z13.array(contentBlockSchema).describe(
|
|
1290
|
+
"(array): The blocks for the email step. Use this when you don't need to set HTML directly."
|
|
1291
|
+
),
|
|
1292
|
+
layoutKey: z13.string().describe("(string): The key of the layout to use for the email step."),
|
|
1200
1293
|
subject: z13.string().describe("(string): The subject of the email step.")
|
|
1201
1294
|
}),
|
|
1202
1295
|
execute: (knockClient, config) => async (params) => {
|
|
@@ -1219,29 +1312,33 @@ Hello, {{ recipient.name }}."
|
|
|
1219
1312
|
channel_key: emailChannels[0].key,
|
|
1220
1313
|
template: {
|
|
1221
1314
|
settings: {
|
|
1222
|
-
layout_key: "default"
|
|
1315
|
+
layout_key: params.layoutKey ?? "default"
|
|
1223
1316
|
},
|
|
1224
1317
|
subject: params.subject,
|
|
1225
|
-
visual_blocks: params.blocks
|
|
1318
|
+
visual_blocks: params.blocks,
|
|
1319
|
+
html_content: params.htmlContent
|
|
1226
1320
|
},
|
|
1227
|
-
ref: generateStepRef("email")
|
|
1321
|
+
ref: params.stepRef ?? generateStepRef("email")
|
|
1228
1322
|
},
|
|
1229
1323
|
config.environment ?? "development"
|
|
1230
1324
|
);
|
|
1231
1325
|
}
|
|
1232
1326
|
});
|
|
1233
|
-
var
|
|
1234
|
-
method: "
|
|
1235
|
-
name: "Create sms step in workflow",
|
|
1327
|
+
var createOrUpdateSmsStepInWorkflow = KnockTool({
|
|
1328
|
+
method: "upsert_workflow_sms_step",
|
|
1329
|
+
name: "Create or update sms step in workflow",
|
|
1236
1330
|
description: `
|
|
1237
|
-
Creates an SMS step in a workflow. Use this tool when you're asked to create an SMS notification and you need to specify the content of the SMS.
|
|
1238
|
-
|
|
1331
|
+
Creates an SMS step in a workflow. Use this tool when you're asked to create an SMS notification and you need to specify the content of the SMS.
|
|
1332
|
+
|
|
1239
1333
|
${SHARED_PROMPTS.workflow}
|
|
1240
1334
|
|
|
1241
1335
|
${SHARED_PROMPTS.liquid}
|
|
1242
1336
|
`,
|
|
1243
1337
|
parameters: z13.object({
|
|
1244
1338
|
workflowKey: z13.string().describe("(string): The key of the workflow to add the step to."),
|
|
1339
|
+
stepRef: z13.string().optional().describe(
|
|
1340
|
+
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1341
|
+
),
|
|
1245
1342
|
content: z13.string().describe("(string): The content of the SMS.")
|
|
1246
1343
|
}),
|
|
1247
1344
|
execute: (knockClient, config) => async (params) => {
|
|
@@ -1265,15 +1362,15 @@ var createSmsStepInWorkflow = KnockTool({
|
|
|
1265
1362
|
template: {
|
|
1266
1363
|
text_body: params.content
|
|
1267
1364
|
},
|
|
1268
|
-
ref: generateStepRef("sms")
|
|
1365
|
+
ref: params.stepRef ?? generateStepRef("sms")
|
|
1269
1366
|
},
|
|
1270
1367
|
config.environment ?? "development"
|
|
1271
1368
|
);
|
|
1272
1369
|
}
|
|
1273
1370
|
});
|
|
1274
|
-
var
|
|
1275
|
-
method: "
|
|
1276
|
-
name: "Create push step in workflow",
|
|
1371
|
+
var createOrUpdatePushStepInWorkflow = KnockTool({
|
|
1372
|
+
method: "upsert_workflow_push_step",
|
|
1373
|
+
name: "Create or update push step in workflow",
|
|
1277
1374
|
description: `
|
|
1278
1375
|
Creates a push step in a workflow. Use this tool when you're asked to create a push notification and you need to specify the content of the push notification.
|
|
1279
1376
|
|
|
@@ -1285,6 +1382,9 @@ var createPushStepInWorkflow = KnockTool({
|
|
|
1285
1382
|
`,
|
|
1286
1383
|
parameters: z13.object({
|
|
1287
1384
|
workflowKey: z13.string().describe("(string): The key of the workflow to add the step to."),
|
|
1385
|
+
stepRef: z13.string().optional().describe(
|
|
1386
|
+
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1387
|
+
),
|
|
1288
1388
|
title: z13.string().describe("(string): The title of the push notification."),
|
|
1289
1389
|
content: z13.string().describe("(string): The content (body) of the push notification.")
|
|
1290
1390
|
}),
|
|
@@ -1310,17 +1410,17 @@ var createPushStepInWorkflow = KnockTool({
|
|
|
1310
1410
|
title: params.title,
|
|
1311
1411
|
text_body: params.content
|
|
1312
1412
|
},
|
|
1313
|
-
ref: generateStepRef("push")
|
|
1413
|
+
ref: params.stepRef ?? generateStepRef("push")
|
|
1314
1414
|
},
|
|
1315
1415
|
config.environment ?? "development"
|
|
1316
1416
|
);
|
|
1317
1417
|
}
|
|
1318
1418
|
});
|
|
1319
|
-
var
|
|
1320
|
-
method: "
|
|
1321
|
-
name: "Create in app feed step in workflow",
|
|
1419
|
+
var createOrUpdateInAppFeedStepInWorkflow = KnockTool({
|
|
1420
|
+
method: "upsert_workflow_in_app_step",
|
|
1421
|
+
name: "Create or update in app feed step in workflow",
|
|
1322
1422
|
description: `
|
|
1323
|
-
Creates an in app feed step in a workflow. Use this tool when you're asked to create an in app feed notification and you need to specify the content of the in app feed notification.
|
|
1423
|
+
Creates an in app feed step in a workflow. Use this tool when you're asked to create an in app feed notification and you need to specify the content of the in app feed notification.
|
|
1324
1424
|
|
|
1325
1425
|
${SHARED_PROMPTS.workflow}
|
|
1326
1426
|
|
|
@@ -1328,6 +1428,9 @@ var createInAppFeedStepInWorkflow = KnockTool({
|
|
|
1328
1428
|
`,
|
|
1329
1429
|
parameters: z13.object({
|
|
1330
1430
|
workflowKey: z13.string().describe("(string): The key of the workflow to add the step to."),
|
|
1431
|
+
stepRef: z13.string().optional().describe(
|
|
1432
|
+
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1433
|
+
),
|
|
1331
1434
|
actionUrl: z13.string().describe(
|
|
1332
1435
|
"(string): The URL to navigate to when the in app feed is tapped."
|
|
1333
1436
|
),
|
|
@@ -1355,15 +1458,15 @@ var createInAppFeedStepInWorkflow = KnockTool({
|
|
|
1355
1458
|
action_url: params.actionUrl,
|
|
1356
1459
|
markdown_body: params.body
|
|
1357
1460
|
},
|
|
1358
|
-
ref: generateStepRef("in_app_feed")
|
|
1461
|
+
ref: params.stepRef ?? generateStepRef("in_app_feed")
|
|
1359
1462
|
},
|
|
1360
1463
|
config.environment ?? "development"
|
|
1361
1464
|
);
|
|
1362
1465
|
}
|
|
1363
1466
|
});
|
|
1364
|
-
var
|
|
1365
|
-
method: "
|
|
1366
|
-
name: "Create chat step in workflow",
|
|
1467
|
+
var createOrUpdateChatStepInWorkflow = KnockTool({
|
|
1468
|
+
method: "upsert_workflow_chat_step",
|
|
1469
|
+
name: "Create or update chat step in workflow",
|
|
1367
1470
|
description: `
|
|
1368
1471
|
Creates a chat step in a workflow. Use this tool when you're asked to create a chat, Slack, Discord, or Microsoft Teams notification and you need to specify the content of the chat notification.
|
|
1369
1472
|
|
|
@@ -1373,6 +1476,9 @@ var createChatStepInWorkflow = KnockTool({
|
|
|
1373
1476
|
`,
|
|
1374
1477
|
parameters: z13.object({
|
|
1375
1478
|
workflowKey: z13.string().describe("(string): The key of the workflow to add the step to."),
|
|
1479
|
+
stepRef: z13.string().describe(
|
|
1480
|
+
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1481
|
+
),
|
|
1376
1482
|
body: z13.string().describe("(string): The markdown content of the notification.")
|
|
1377
1483
|
}),
|
|
1378
1484
|
execute: (knockClient, config) => async (params) => {
|
|
@@ -1396,20 +1502,20 @@ var createChatStepInWorkflow = KnockTool({
|
|
|
1396
1502
|
template: {
|
|
1397
1503
|
markdown_body: params.body
|
|
1398
1504
|
},
|
|
1399
|
-
ref: generateStepRef("chat")
|
|
1505
|
+
ref: params.stepRef ?? generateStepRef("chat")
|
|
1400
1506
|
},
|
|
1401
1507
|
config.environment ?? "development"
|
|
1402
1508
|
);
|
|
1403
1509
|
}
|
|
1404
1510
|
});
|
|
1405
|
-
var
|
|
1406
|
-
method: "
|
|
1407
|
-
name: "Create delay step in workflow",
|
|
1511
|
+
var createOrUpdateDelayStepInWorkflow = KnockTool({
|
|
1512
|
+
method: "upsert_workflow_delay_step",
|
|
1513
|
+
name: "Create or update delay step in workflow",
|
|
1408
1514
|
description: `
|
|
1409
1515
|
Creates a delay step in a workflow. Use this tool when you're asked to add a delay to the workflow that pauses, or waits for a period of time before continuing.
|
|
1410
1516
|
|
|
1411
1517
|
${SHARED_PROMPTS.workflow}
|
|
1412
|
-
|
|
1518
|
+
|
|
1413
1519
|
Delays are specified in "unit" and "value" pairs. The only valid units are "seconds", "minutes", "hours", and "days".
|
|
1414
1520
|
|
|
1415
1521
|
<example>
|
|
@@ -1421,6 +1527,9 @@ var createDelayStepInWorkflow = KnockTool({
|
|
|
1421
1527
|
`,
|
|
1422
1528
|
parameters: z13.object({
|
|
1423
1529
|
workflowKey: z13.string().describe("(string): The key of the workflow to add the step to."),
|
|
1530
|
+
stepRef: z13.string().optional().describe(
|
|
1531
|
+
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1532
|
+
),
|
|
1424
1533
|
delayValue: z13.number().describe("(number): The value of the delay."),
|
|
1425
1534
|
delayUnit: z13.enum(["seconds", "minutes", "hours", "days"]).describe("(enum): The unit of the delay.")
|
|
1426
1535
|
}),
|
|
@@ -1444,7 +1553,7 @@ var createDelayStepInWorkflow = KnockTool({
|
|
|
1444
1553
|
unit: params.delayUnit
|
|
1445
1554
|
}
|
|
1446
1555
|
},
|
|
1447
|
-
ref: generateStepRef("delay")
|
|
1556
|
+
ref: params.stepRef ?? generateStepRef("delay")
|
|
1448
1557
|
}
|
|
1449
1558
|
]
|
|
1450
1559
|
}
|
|
@@ -1456,9 +1565,9 @@ var createDelayStepInWorkflow = KnockTool({
|
|
|
1456
1565
|
return serializeWorkflowResponse(result.workflow);
|
|
1457
1566
|
}
|
|
1458
1567
|
});
|
|
1459
|
-
var
|
|
1460
|
-
method: "
|
|
1461
|
-
name: "Create batch step in workflow",
|
|
1568
|
+
var createOrUpdateBatchStepInWorkflow = KnockTool({
|
|
1569
|
+
method: "upsert_workflow_batch_step",
|
|
1570
|
+
name: "Create or update batch step in workflow",
|
|
1462
1571
|
description: `
|
|
1463
1572
|
Creates a batch step in a workflow. Use this tool when you're asked to create a batch step or asked to add digesting behavior to a workflow. The batch step collects multiple workflow triggers for a single recipient over a period of time and then flushes the content to the next step.
|
|
1464
1573
|
|
|
@@ -1477,6 +1586,9 @@ var createBatchStepInWorkflow = KnockTool({
|
|
|
1477
1586
|
`,
|
|
1478
1587
|
parameters: z13.object({
|
|
1479
1588
|
workflowKey: z13.string().describe("(string): The key of the workflow to add the step to."),
|
|
1589
|
+
stepRef: z13.string().optional().describe(
|
|
1590
|
+
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1591
|
+
),
|
|
1480
1592
|
batchWindow: z13.object({
|
|
1481
1593
|
value: z13.number().describe("(number): The value of the batch window."),
|
|
1482
1594
|
unit: z13.enum(["seconds", "minutes", "hours", "days"]).describe("(enum): The unit of the batch window.")
|
|
@@ -1498,7 +1610,7 @@ var createBatchStepInWorkflow = KnockTool({
|
|
|
1498
1610
|
unit: params.batchWindow.unit
|
|
1499
1611
|
}
|
|
1500
1612
|
},
|
|
1501
|
-
ref: generateStepRef("batch")
|
|
1613
|
+
ref: params.stepRef ?? generateStepRef("batch")
|
|
1502
1614
|
},
|
|
1503
1615
|
config.environment ?? "development"
|
|
1504
1616
|
);
|
|
@@ -1506,14 +1618,14 @@ var createBatchStepInWorkflow = KnockTool({
|
|
|
1506
1618
|
});
|
|
1507
1619
|
var workflowStepTools = {
|
|
1508
1620
|
// Channel steps
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1621
|
+
createOrUpdateEmailStepInWorkflow,
|
|
1622
|
+
createOrUpdateSmsStepInWorkflow,
|
|
1623
|
+
createOrUpdatePushStepInWorkflow,
|
|
1624
|
+
createOrUpdateInAppFeedStepInWorkflow,
|
|
1625
|
+
createOrUpdateChatStepInWorkflow,
|
|
1514
1626
|
// Function steps
|
|
1515
|
-
|
|
1516
|
-
|
|
1627
|
+
createOrUpdateDelayStepInWorkflow,
|
|
1628
|
+
createOrUpdateBatchStepInWorkflow
|
|
1517
1629
|
};
|
|
1518
1630
|
|
|
1519
1631
|
// src/lib/tools/workflows.ts
|
|
@@ -1526,6 +1638,16 @@ function serializeWorkflowResponse(workflow2) {
|
|
|
1526
1638
|
schema: workflow2.trigger_data_json_schema
|
|
1527
1639
|
};
|
|
1528
1640
|
}
|
|
1641
|
+
function serializeFullWorkflowResponse(workflow2) {
|
|
1642
|
+
return {
|
|
1643
|
+
key: workflow2.key,
|
|
1644
|
+
name: workflow2.name,
|
|
1645
|
+
description: workflow2.description,
|
|
1646
|
+
categories: workflow2.categories,
|
|
1647
|
+
schema: workflow2.trigger_data_json_schema,
|
|
1648
|
+
steps: workflow2.steps
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1529
1651
|
var listWorkflows = KnockTool({
|
|
1530
1652
|
method: "list_workflows",
|
|
1531
1653
|
name: "List workflows",
|
|
@@ -1566,7 +1688,7 @@ var getWorkflow = KnockTool({
|
|
|
1566
1688
|
const workflow2 = await knockClient.workflows.retrieve(params.workflowKey, {
|
|
1567
1689
|
environment: params.environment ?? config.environment ?? "development"
|
|
1568
1690
|
});
|
|
1569
|
-
return
|
|
1691
|
+
return serializeFullWorkflowResponse(workflow2);
|
|
1570
1692
|
}
|
|
1571
1693
|
});
|
|
1572
1694
|
var triggerWorkflow = KnockTool({
|
|
@@ -1740,4 +1862,4 @@ export {
|
|
|
1740
1862
|
getToolsByPermissionsInCategories,
|
|
1741
1863
|
getToolMap
|
|
1742
1864
|
};
|
|
1743
|
-
//# sourceMappingURL=chunk-
|
|
1865
|
+
//# sourceMappingURL=chunk-QG5UJT76.js.map
|