@knocklabs/agent-toolkit 0.5.1 → 0.5.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 +2 -2
- package/dist/{chunk-UBRPLPCX.js → chunk-BT6KDK3Z.js} +2 -2
- package/dist/{chunk-UBRPLPCX.js.map → chunk-BT6KDK3Z.js.map} +1 -1
- package/dist/{chunk-3Q6IG57F.js → chunk-CRW3ZMHM.js} +155 -30
- package/dist/chunk-CRW3ZMHM.js.map +1 -0
- package/dist/{chunk-OA5U6LZU.js → chunk-LLIVREQ2.js} +3 -3
- package/dist/langchain/index.js +2 -2
- package/dist/mastra/index.js +2 -2
- package/dist/modelcontextprotocol/index.js +2 -2
- package/dist/modelcontextprotocol/local-server.js +3 -3
- package/dist/openai/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-3Q6IG57F.js.map +0 -1
- /package/dist/{chunk-OA5U6LZU.js.map → chunk-LLIVREQ2.js.map} +0 -0
package/dist/ai-sdk/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
} from "../chunk-X3LAGKQW.js";
|
|
6
6
|
import {
|
|
7
7
|
createKnockClient
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-BT6KDK3Z.js";
|
|
9
9
|
import {
|
|
10
10
|
getToolMap,
|
|
11
11
|
getToolsByPermissionsInCategories
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-CRW3ZMHM.js";
|
|
13
13
|
import "../chunk-G3PMV62Z.js";
|
|
14
14
|
|
|
15
15
|
// src/ai-sdk/tool-converter.ts
|
|
@@ -5,7 +5,7 @@ import { Knock } from "@knocklabs/node";
|
|
|
5
5
|
// package.json
|
|
6
6
|
var package_default = {
|
|
7
7
|
name: "@knocklabs/agent-toolkit",
|
|
8
|
-
version: "0.5.
|
|
8
|
+
version: "0.5.3",
|
|
9
9
|
description: "A toolkit for working with Knock in Agent workflows.",
|
|
10
10
|
main: "src/index.js",
|
|
11
11
|
scripts: {
|
|
@@ -151,4 +151,4 @@ var createKnockClient = (config) => {
|
|
|
151
151
|
export {
|
|
152
152
|
createKnockClient
|
|
153
153
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
//# sourceMappingURL=chunk-BT6KDK3Z.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/knock-client.ts","../package.json"],"sourcesContent":["import KnockMgmt from \"@knocklabs/mgmt\";\nimport { Knock } from \"@knocklabs/node\";\n\nimport pkg from \"../../package.json\";\nimport { Config } from \"../types.js\";\n\nconst serviceTokensToApiClients: Record<string, Record<string, Knock>> = {};\n\ntype KnockClient = ReturnType<typeof createKnockClient>;\n\n// Include a custom header to identify all client requests in the API logs\nconst knockClientHeaders = {\n \"X-Knock-Client\": `knock/agent-toolkit@${pkg.version}`,\n};\n\nconst createKnockClient = (config: Config) => {\n const serviceToken = config.serviceToken ?? process.env.KNOCK_SERVICE_TOKEN;\n\n if (!serviceToken) {\n throw new Error(\n \"Service token is required. Please set the `serviceToken` property in the config or the `KNOCK_SERVICE_TOKEN` environment variable.\"\n );\n }\n\n const client = new KnockMgmt({\n serviceToken,\n defaultHeaders: knockClientHeaders,\n });\n\n return Object.assign(client, {\n publicApi: async (environmentSlug?: string): Promise<Knock> => {\n const environment =\n environmentSlug ?? config.environment ?? \"development\";\n\n // If the client already exists for this service token and environment, return it\n if (serviceTokensToApiClients?.[serviceToken]?.[environment]) {\n return serviceTokensToApiClients[serviceToken][environment];\n }\n\n // Otherwise, fetch a public API key for this service token and environment\n const { api_key } = await client.apiKeys.exchange({ environment });\n\n // Create a new Knock client with the public API key\n const knock = new Knock({\n apiKey: api_key,\n defaultHeaders: knockClientHeaders,\n });\n\n // Store the client in the cache\n if (!serviceTokensToApiClients[serviceToken]) {\n serviceTokensToApiClients[serviceToken] = {};\n }\n\n serviceTokensToApiClients[serviceToken][environment] = knock;\n\n return knock;\n },\n });\n};\n\nexport { createKnockClient, type KnockClient };\n","{\n \"name\": \"@knocklabs/agent-toolkit\",\n \"version\": \"0.5.
|
|
1
|
+
{"version":3,"sources":["../src/lib/knock-client.ts","../package.json"],"sourcesContent":["import KnockMgmt from \"@knocklabs/mgmt\";\nimport { Knock } from \"@knocklabs/node\";\n\nimport pkg from \"../../package.json\";\nimport { Config } from \"../types.js\";\n\nconst serviceTokensToApiClients: Record<string, Record<string, Knock>> = {};\n\ntype KnockClient = ReturnType<typeof createKnockClient>;\n\n// Include a custom header to identify all client requests in the API logs\nconst knockClientHeaders = {\n \"X-Knock-Client\": `knock/agent-toolkit@${pkg.version}`,\n};\n\nconst createKnockClient = (config: Config) => {\n const serviceToken = config.serviceToken ?? process.env.KNOCK_SERVICE_TOKEN;\n\n if (!serviceToken) {\n throw new Error(\n \"Service token is required. Please set the `serviceToken` property in the config or the `KNOCK_SERVICE_TOKEN` environment variable.\"\n );\n }\n\n const client = new KnockMgmt({\n serviceToken,\n defaultHeaders: knockClientHeaders,\n });\n\n return Object.assign(client, {\n publicApi: async (environmentSlug?: string): Promise<Knock> => {\n const environment =\n environmentSlug ?? config.environment ?? \"development\";\n\n // If the client already exists for this service token and environment, return it\n if (serviceTokensToApiClients?.[serviceToken]?.[environment]) {\n return serviceTokensToApiClients[serviceToken][environment];\n }\n\n // Otherwise, fetch a public API key for this service token and environment\n const { api_key } = await client.apiKeys.exchange({ environment });\n\n // Create a new Knock client with the public API key\n const knock = new Knock({\n apiKey: api_key,\n defaultHeaders: knockClientHeaders,\n });\n\n // Store the client in the cache\n if (!serviceTokensToApiClients[serviceToken]) {\n serviceTokensToApiClients[serviceToken] = {};\n }\n\n serviceTokensToApiClients[serviceToken][environment] = knock;\n\n return knock;\n },\n });\n};\n\nexport { createKnockClient, type KnockClient };\n","{\n \"name\": \"@knocklabs/agent-toolkit\",\n \"version\": \"0.5.3\",\n \"description\": \"A toolkit for working with Knock in Agent workflows.\",\n \"main\": \"src/index.js\",\n \"scripts\": {\n \"build\": \"tsup --env.NODE_ENV production\",\n \"clean\": \"rimraf ./dist\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint src --ext .ts,.tsx\",\n \"lint:fix\": \"eslint src --ext .ts,.tsx --fix\",\n \"format\": \"prettier --write \\\"src/**/*.{ts,tsx}\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.{ts,tsx}\\\"\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"release\": \"npm run build && npm run release:publish && changeset tag\",\n \"release:publish\": \"npm publish --access public --tolerate-republish\"\n },\n \"author\": \"Knock\",\n \"license\": \"MIT\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \"./openai\": {\n \"types\": \"./dist/openai/index.d.ts\",\n \"default\": \"./dist/openai/index.js\"\n },\n \"./ai-sdk\": {\n \"types\": \"./dist/ai-sdk/index.d.ts\",\n \"default\": \"./dist/ai-sdk/index.js\"\n },\n \"./langchain\": {\n \"types\": \"./dist/langchain/index.d.ts\",\n \"default\": \"./dist/langchain/index.js\"\n },\n \"./mastra\": {\n \"types\": \"./dist/mastra/index.d.ts\",\n \"default\": \"./dist/mastra/index.js\"\n },\n \"./modelcontextprotocol\": {\n \"types\": \"./dist/modelcontextprotocol/index.d.ts\",\n \"default\": \"./dist/modelcontextprotocol/index.js\"\n },\n \"./human-in-the-loop\": {\n \"types\": \"./dist/human-in-the-loop/index.d.ts\",\n \"default\": \"./dist/human-in-the-loop/index.js\"\n },\n \"./types\": {\n \"types\": \"./dist/types.d.ts\"\n }\n },\n \"bin\": {\n \"local-mcp\": \"dist/modelcontextprotocol/local-server.js\"\n },\n \"files\": [\n \"dist\"\n ],\n \"dependencies\": {\n \"@knocklabs/mgmt\": \"^0.2.0\",\n \"@knocklabs/node\": \"^1.10.3\",\n \"@modelcontextprotocol/sdk\": \"^1.7.0\",\n \"@sentry/node\": \"^10.5.0\",\n \"json-schema-to-zod\": \"^2.6.1\",\n \"uuid\": \"^11.1.0\",\n \"yargs\": \"^17.7.2\",\n \"zod\": \"^3.24.2\",\n \"zod-to-json-schema\": \"^3.24.5\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^2.28.1\",\n \"@eslint/js\": \"^9.24.0\",\n \"@langchain/core\": \"^0.3.45\",\n \"@types/node\": \"^22.13.10\",\n \"@types/yargs\": \"^17.0.33\",\n \"@typescript-eslint/eslint-plugin\": \"^8.29.1\",\n \"@typescript-eslint/parser\": \"^8.29.1\",\n \"ai\": \"^4.2.8\",\n \"eslint\": \"^9.24.0\",\n \"eslint-config-prettier\": \"^10.1.2\",\n \"eslint-import-resolver-typescript\": \"^4.3.2\",\n \"eslint-plugin-import\": \"^2.31.0\",\n \"eslint-plugin-prettier\": \"^5.2.6\",\n \"openai\": \"^4.90.0\",\n \"prettier\": \"^3.5.3\",\n \"rimraf\": \"^6.0.1\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.8.2\",\n \"typescript-eslint\": \"^8.29.1\",\n \"vitest\": \"^1.3.1\"\n },\n \"peerDependencies\": {\n \"@mastra/core\": \"^0.10.3\",\n \"ai\": \"^4.0.0\",\n \"openai\": \"^4.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"ai\": {\n \"optional\": true\n }\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"],"mappings":";AAAA,OAAO,eAAe;AACtB,SAAS,aAAa;;;ACDtB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,MAAQ;AAAA,EACR,SAAW;AAAA,IACT,OAAS;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,MAAQ;AAAA,IACR,YAAY;AAAA,IACZ,QAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,SAAW;AAAA,IACX,mBAAmB;AAAA,EACrB;AAAA,EACA,Q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179
179
|
}
|
|
180
|
+
var getEmailLayout = KnockTool({
|
|
181
|
+
method: "get_email_layout",
|
|
182
|
+
name: "Get email layout",
|
|
183
|
+
description: `Retrieves a single email layout by its key. Returns the layout's name, HTML content, and text content. Use this tool when you need to inspect the details of a specific email layout.`,
|
|
184
|
+
parameters: z4.object({
|
|
185
|
+
environment: z4.string().optional().describe(
|
|
186
|
+
"(string): The environment to retrieve the email layout from. Defaults to `development`."
|
|
187
|
+
),
|
|
188
|
+
key: z4.string().describe("(string): The key of the email layout to retrieve.")
|
|
189
|
+
}),
|
|
190
|
+
execute: (knockClient, config) => async (params) => {
|
|
191
|
+
const response = await knockClient.emailLayouts.retrieve(params.key, {
|
|
192
|
+
environment: params.environment ?? config.environment ?? "development"
|
|
193
|
+
});
|
|
194
|
+
return serializeEmailLayoutResponse(response.email_layout);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
180
197
|
var listEmailLayouts = KnockTool({
|
|
181
198
|
method: "list_email_layouts",
|
|
182
199
|
name: "List email layouts",
|
|
@@ -231,11 +248,12 @@ var createOrUpdateEmailLayout = KnockTool({
|
|
|
231
248
|
}
|
|
232
249
|
});
|
|
233
250
|
var emailLayouts = {
|
|
251
|
+
getEmailLayout,
|
|
234
252
|
listEmailLayouts,
|
|
235
253
|
createOrUpdateEmailLayout
|
|
236
254
|
};
|
|
237
255
|
var permissions4 = {
|
|
238
|
-
read: ["listEmailLayouts"],
|
|
256
|
+
read: ["listEmailLayouts", "getEmailLayout"],
|
|
239
257
|
manage: ["createOrUpdateEmailLayout"]
|
|
240
258
|
};
|
|
241
259
|
|
|
@@ -658,6 +676,23 @@ var permissions7 = {
|
|
|
658
676
|
|
|
659
677
|
// src/lib/tools/messages.ts
|
|
660
678
|
import { z as z8 } from "zod";
|
|
679
|
+
var getMessage = KnockTool({
|
|
680
|
+
method: "get_message",
|
|
681
|
+
name: "Get message",
|
|
682
|
+
description: `
|
|
683
|
+
Retrieves a single message by its ID, including its current status and engagement statuses (e.g. seen, read, interacted, link_clicked). Use this tool when you need to check the delivery status or engagement state of a specific message.
|
|
684
|
+
`,
|
|
685
|
+
parameters: z8.object({
|
|
686
|
+
environment: z8.string().optional().describe(
|
|
687
|
+
"(string): The environment to retrieve the message from. Defaults to `development`."
|
|
688
|
+
),
|
|
689
|
+
messageId: z8.string().describe("(string): The ID of the message to retrieve.")
|
|
690
|
+
}),
|
|
691
|
+
execute: (knockClient) => async (params) => {
|
|
692
|
+
const publicClient = await knockClient.publicApi(params.environment);
|
|
693
|
+
return await publicClient.messages.get(params.messageId);
|
|
694
|
+
}
|
|
695
|
+
});
|
|
661
696
|
var getMessageContent = KnockTool({
|
|
662
697
|
method: "get_message_content",
|
|
663
698
|
name: "Get message content",
|
|
@@ -675,11 +710,55 @@ var getMessageContent = KnockTool({
|
|
|
675
710
|
return await publicClient.messages.getContent(params.messageId);
|
|
676
711
|
}
|
|
677
712
|
});
|
|
713
|
+
var getMessageDeliveryLogs = KnockTool({
|
|
714
|
+
method: "get_message_delivery_logs",
|
|
715
|
+
name: "Get message delivery logs",
|
|
716
|
+
description: `
|
|
717
|
+
Retrieves the delivery logs for a specific message. Delivery logs contain details about each delivery attempt, including any errors that occurred. Use this tool when you need to debug why a message was not delivered or to inspect delivery attempt details.
|
|
718
|
+
`,
|
|
719
|
+
parameters: z8.object({
|
|
720
|
+
environment: z8.string().optional().describe(
|
|
721
|
+
"(string): The environment to retrieve the delivery logs from. Defaults to `development`."
|
|
722
|
+
),
|
|
723
|
+
messageId: z8.string().describe(
|
|
724
|
+
"(string): The ID of the message to retrieve delivery logs for."
|
|
725
|
+
)
|
|
726
|
+
}),
|
|
727
|
+
execute: (knockClient) => async (params) => {
|
|
728
|
+
const publicClient = await knockClient.publicApi(params.environment);
|
|
729
|
+
return await publicClient.messages.listDeliveryLogs(params.messageId);
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
var getMessageEvents = KnockTool({
|
|
733
|
+
method: "get_message_events",
|
|
734
|
+
name: "Get message events",
|
|
735
|
+
description: `
|
|
736
|
+
Retrieves the event timeline for a specific message. Events include delivery, bounce, open, click, and other engagement events. Use this tool when you need to see the full lifecycle of a message.
|
|
737
|
+
`,
|
|
738
|
+
parameters: z8.object({
|
|
739
|
+
environment: z8.string().optional().describe(
|
|
740
|
+
"(string): The environment to retrieve the message events from. Defaults to `development`."
|
|
741
|
+
),
|
|
742
|
+
messageId: z8.string().describe("(string): The ID of the message to retrieve events for.")
|
|
743
|
+
}),
|
|
744
|
+
execute: (knockClient) => async (params) => {
|
|
745
|
+
const publicClient = await knockClient.publicApi(params.environment);
|
|
746
|
+
return await publicClient.messages.listEvents(params.messageId);
|
|
747
|
+
}
|
|
748
|
+
});
|
|
678
749
|
var messages = {
|
|
679
|
-
|
|
750
|
+
getMessage,
|
|
751
|
+
getMessageContent,
|
|
752
|
+
getMessageDeliveryLogs,
|
|
753
|
+
getMessageEvents
|
|
680
754
|
};
|
|
681
755
|
var permissions8 = {
|
|
682
|
-
read: [
|
|
756
|
+
read: [
|
|
757
|
+
"getMessage",
|
|
758
|
+
"getMessageContent",
|
|
759
|
+
"getMessageDeliveryLogs",
|
|
760
|
+
"getMessageEvents"
|
|
761
|
+
]
|
|
683
762
|
};
|
|
684
763
|
|
|
685
764
|
// src/lib/tools/objects.ts
|
|
@@ -1317,7 +1396,7 @@ var getUserMessages = KnockTool({
|
|
|
1317
1396
|
}),
|
|
1318
1397
|
execute: (knockClient, config) => async (params) => {
|
|
1319
1398
|
const publicClient = await knockClient.publicApi(params.environment);
|
|
1320
|
-
const messages2 = await publicClient.users.
|
|
1399
|
+
const messages2 = await publicClient.users.listMessages(
|
|
1321
1400
|
params.userId ?? config.userId,
|
|
1322
1401
|
{
|
|
1323
1402
|
workflow_run_id: params.workflowRunId
|
|
@@ -1551,6 +1630,12 @@ Hello, {{ recipient.name }}."
|
|
|
1551
1630
|
stepRef: z14.string().optional().describe(
|
|
1552
1631
|
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1553
1632
|
),
|
|
1633
|
+
channelKey: z14.string().optional().describe(
|
|
1634
|
+
"(string): The key of the channel to use for this step. Use `list_channels` to see available channels. If not provided, the first email channel will be used."
|
|
1635
|
+
),
|
|
1636
|
+
environment: z14.string().optional().describe(
|
|
1637
|
+
"(string): The environment to operate in. Defaults to `development`."
|
|
1638
|
+
),
|
|
1554
1639
|
htmlContent: z14.string().optional().describe(
|
|
1555
1640
|
"(string): The HTML content of the email template. Use this when not setting blocks."
|
|
1556
1641
|
),
|
|
@@ -1561,14 +1646,15 @@ Hello, {{ recipient.name }}."
|
|
|
1561
1646
|
subject: z14.string().describe("(string): The subject of the email step.")
|
|
1562
1647
|
}),
|
|
1563
1648
|
execute: (knockClient, config) => async (params) => {
|
|
1649
|
+
const environment = params.environment ?? config.environment ?? "development";
|
|
1564
1650
|
const workflow2 = await knockClient.workflows.retrieve(params.workflowKey, {
|
|
1565
|
-
environment
|
|
1651
|
+
environment
|
|
1566
1652
|
});
|
|
1567
1653
|
const emailChannelsPage = await knockClient.channels.list();
|
|
1568
1654
|
const emailChannels = emailChannelsPage.entries.filter(
|
|
1569
1655
|
(channel) => channel.type === "email"
|
|
1570
1656
|
);
|
|
1571
|
-
if (emailChannels.length === 0) {
|
|
1657
|
+
if (!params.channelKey && emailChannels.length === 0) {
|
|
1572
1658
|
throw new Error("No email channels found");
|
|
1573
1659
|
}
|
|
1574
1660
|
return await updateWorkflowWithStep(
|
|
@@ -1577,7 +1663,7 @@ Hello, {{ recipient.name }}."
|
|
|
1577
1663
|
// @ts-expect-error
|
|
1578
1664
|
{
|
|
1579
1665
|
type: "channel",
|
|
1580
|
-
channel_key: emailChannels[0].key,
|
|
1666
|
+
channel_key: params.channelKey ?? emailChannels[0].key,
|
|
1581
1667
|
template: {
|
|
1582
1668
|
settings: {
|
|
1583
1669
|
layout_key: params.layoutKey ?? "default"
|
|
@@ -1588,7 +1674,7 @@ Hello, {{ recipient.name }}."
|
|
|
1588
1674
|
},
|
|
1589
1675
|
ref: params.stepRef ?? generateStepRef("email")
|
|
1590
1676
|
},
|
|
1591
|
-
|
|
1677
|
+
environment
|
|
1592
1678
|
);
|
|
1593
1679
|
}
|
|
1594
1680
|
});
|
|
@@ -1607,17 +1693,24 @@ var createOrUpdateSmsStepInWorkflow = KnockTool({
|
|
|
1607
1693
|
stepRef: z14.string().optional().describe(
|
|
1608
1694
|
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1609
1695
|
),
|
|
1696
|
+
channelKey: z14.string().optional().describe(
|
|
1697
|
+
"(string): The key of the channel to use for this step. Use `list_channels` to see available channels. If not provided, the first SMS channel will be used."
|
|
1698
|
+
),
|
|
1699
|
+
environment: z14.string().optional().describe(
|
|
1700
|
+
"(string): The environment to operate in. Defaults to `development`."
|
|
1701
|
+
),
|
|
1610
1702
|
content: z14.string().describe("(string): The content of the SMS.")
|
|
1611
1703
|
}),
|
|
1612
1704
|
execute: (knockClient, config) => async (params) => {
|
|
1705
|
+
const environment = params.environment ?? config.environment ?? "development";
|
|
1613
1706
|
const workflow2 = await knockClient.workflows.retrieve(params.workflowKey, {
|
|
1614
|
-
environment
|
|
1707
|
+
environment
|
|
1615
1708
|
});
|
|
1616
1709
|
const smsChannelsPage = await knockClient.channels.list();
|
|
1617
1710
|
const smsChannels = smsChannelsPage.entries.filter(
|
|
1618
1711
|
(channel) => channel.type === "sms"
|
|
1619
1712
|
);
|
|
1620
|
-
if (smsChannels.length === 0) {
|
|
1713
|
+
if (!params.channelKey && smsChannels.length === 0) {
|
|
1621
1714
|
throw new Error("No SMS channels found");
|
|
1622
1715
|
}
|
|
1623
1716
|
return await updateWorkflowWithStep(
|
|
@@ -1626,13 +1719,13 @@ var createOrUpdateSmsStepInWorkflow = KnockTool({
|
|
|
1626
1719
|
// @ts-expect-error
|
|
1627
1720
|
{
|
|
1628
1721
|
type: "channel",
|
|
1629
|
-
channel_key: smsChannels[0].key,
|
|
1722
|
+
channel_key: params.channelKey ?? smsChannels[0].key,
|
|
1630
1723
|
template: {
|
|
1631
1724
|
text_body: params.content
|
|
1632
1725
|
},
|
|
1633
1726
|
ref: params.stepRef ?? generateStepRef("sms")
|
|
1634
1727
|
},
|
|
1635
|
-
|
|
1728
|
+
environment
|
|
1636
1729
|
);
|
|
1637
1730
|
}
|
|
1638
1731
|
});
|
|
@@ -1653,18 +1746,25 @@ var createOrUpdatePushStepInWorkflow = KnockTool({
|
|
|
1653
1746
|
stepRef: z14.string().optional().describe(
|
|
1654
1747
|
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1655
1748
|
),
|
|
1749
|
+
channelKey: z14.string().optional().describe(
|
|
1750
|
+
"(string): The key of the channel to use for this step. Use `list_channels` to see available channels. If not provided, the first push channel will be used."
|
|
1751
|
+
),
|
|
1752
|
+
environment: z14.string().optional().describe(
|
|
1753
|
+
"(string): The environment to operate in. Defaults to `development`."
|
|
1754
|
+
),
|
|
1656
1755
|
title: z14.string().describe("(string): The title of the push notification."),
|
|
1657
1756
|
content: z14.string().describe("(string): The content (body) of the push notification.")
|
|
1658
1757
|
}),
|
|
1659
1758
|
execute: (knockClient, config) => async (params) => {
|
|
1759
|
+
const environment = params.environment ?? config.environment ?? "development";
|
|
1660
1760
|
const workflow2 = await knockClient.workflows.retrieve(params.workflowKey, {
|
|
1661
|
-
environment
|
|
1761
|
+
environment
|
|
1662
1762
|
});
|
|
1663
1763
|
const pushChannelsPage = await knockClient.channels.list();
|
|
1664
1764
|
const pushChannels = pushChannelsPage.entries.filter(
|
|
1665
1765
|
(channel) => channel.type === "push"
|
|
1666
1766
|
);
|
|
1667
|
-
if (pushChannels.length === 0) {
|
|
1767
|
+
if (!params.channelKey && pushChannels.length === 0) {
|
|
1668
1768
|
throw new Error("No push channels found");
|
|
1669
1769
|
}
|
|
1670
1770
|
return await updateWorkflowWithStep(
|
|
@@ -1673,14 +1773,17 @@ var createOrUpdatePushStepInWorkflow = KnockTool({
|
|
|
1673
1773
|
// @ts-expect-error
|
|
1674
1774
|
{
|
|
1675
1775
|
type: "channel",
|
|
1676
|
-
channel_key: pushChannels[0].key,
|
|
1776
|
+
channel_key: params.channelKey ?? pushChannels[0].key,
|
|
1677
1777
|
template: {
|
|
1678
1778
|
title: params.title,
|
|
1679
|
-
text_body: params.content
|
|
1779
|
+
text_body: params.content,
|
|
1780
|
+
settings: {
|
|
1781
|
+
delivery_type: "content"
|
|
1782
|
+
}
|
|
1680
1783
|
},
|
|
1681
1784
|
ref: params.stepRef ?? generateStepRef("push")
|
|
1682
1785
|
},
|
|
1683
|
-
|
|
1786
|
+
environment
|
|
1684
1787
|
);
|
|
1685
1788
|
}
|
|
1686
1789
|
});
|
|
@@ -1699,20 +1802,27 @@ var createOrUpdateInAppFeedStepInWorkflow = KnockTool({
|
|
|
1699
1802
|
stepRef: z14.string().optional().describe(
|
|
1700
1803
|
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1701
1804
|
),
|
|
1805
|
+
channelKey: z14.string().optional().describe(
|
|
1806
|
+
"(string): The key of the channel to use for this step. Use `list_channels` to see available channels. If not provided, the first in-app feed channel will be used."
|
|
1807
|
+
),
|
|
1808
|
+
environment: z14.string().optional().describe(
|
|
1809
|
+
"(string): The environment to operate in. Defaults to `development`."
|
|
1810
|
+
),
|
|
1702
1811
|
actionUrl: z14.string().describe(
|
|
1703
1812
|
"(string): The URL to navigate to when the in app feed is tapped."
|
|
1704
1813
|
),
|
|
1705
1814
|
body: z14.string().describe("(string): The markdown content of the in app feed.")
|
|
1706
1815
|
}),
|
|
1707
1816
|
execute: (knockClient, config) => async (params) => {
|
|
1817
|
+
const environment = params.environment ?? config.environment ?? "development";
|
|
1708
1818
|
const workflow2 = await knockClient.workflows.retrieve(params.workflowKey, {
|
|
1709
|
-
environment
|
|
1819
|
+
environment
|
|
1710
1820
|
});
|
|
1711
1821
|
const inAppChannelsPage = await knockClient.channels.list();
|
|
1712
1822
|
const inAppChannels = inAppChannelsPage.entries.filter(
|
|
1713
1823
|
(channel) => channel.type === "in_app_feed"
|
|
1714
1824
|
);
|
|
1715
|
-
if (inAppChannels.length === 0) {
|
|
1825
|
+
if (!params.channelKey && inAppChannels.length === 0) {
|
|
1716
1826
|
throw new Error("No in app channels found");
|
|
1717
1827
|
}
|
|
1718
1828
|
return await updateWorkflowWithStep(
|
|
@@ -1721,14 +1831,14 @@ var createOrUpdateInAppFeedStepInWorkflow = KnockTool({
|
|
|
1721
1831
|
// @ts-expect-error
|
|
1722
1832
|
{
|
|
1723
1833
|
type: "channel",
|
|
1724
|
-
channel_key: inAppChannels[0].key,
|
|
1834
|
+
channel_key: params.channelKey ?? inAppChannels[0].key,
|
|
1725
1835
|
template: {
|
|
1726
1836
|
action_url: params.actionUrl,
|
|
1727
1837
|
markdown_body: params.body
|
|
1728
1838
|
},
|
|
1729
1839
|
ref: params.stepRef ?? generateStepRef("in_app_feed")
|
|
1730
1840
|
},
|
|
1731
|
-
|
|
1841
|
+
environment
|
|
1732
1842
|
);
|
|
1733
1843
|
}
|
|
1734
1844
|
});
|
|
@@ -1747,17 +1857,24 @@ var createOrUpdateChatStepInWorkflow = KnockTool({
|
|
|
1747
1857
|
stepRef: z14.string().describe(
|
|
1748
1858
|
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1749
1859
|
),
|
|
1860
|
+
channelKey: z14.string().optional().describe(
|
|
1861
|
+
"(string): The key of the channel to use for this step. Use `list_channels` to see available channels. If not provided, the first chat channel will be used."
|
|
1862
|
+
),
|
|
1863
|
+
environment: z14.string().optional().describe(
|
|
1864
|
+
"(string): The environment to operate in. Defaults to `development`."
|
|
1865
|
+
),
|
|
1750
1866
|
body: z14.string().describe("(string): The markdown content of the notification.")
|
|
1751
1867
|
}),
|
|
1752
1868
|
execute: (knockClient, config) => async (params) => {
|
|
1869
|
+
const environment = params.environment ?? config.environment ?? "development";
|
|
1753
1870
|
const workflow2 = await knockClient.workflows.retrieve(params.workflowKey, {
|
|
1754
|
-
environment
|
|
1871
|
+
environment
|
|
1755
1872
|
});
|
|
1756
1873
|
const chatChannelsPage = await knockClient.channels.list();
|
|
1757
1874
|
const chatChannels = chatChannelsPage.entries.filter(
|
|
1758
1875
|
(channel) => channel.type === "chat"
|
|
1759
1876
|
);
|
|
1760
|
-
if (chatChannels.length === 0) {
|
|
1877
|
+
if (!params.channelKey && chatChannels.length === 0) {
|
|
1761
1878
|
throw new Error("No chat channels found");
|
|
1762
1879
|
}
|
|
1763
1880
|
return await updateWorkflowWithStep(
|
|
@@ -1766,13 +1883,13 @@ var createOrUpdateChatStepInWorkflow = KnockTool({
|
|
|
1766
1883
|
// @ts-expect-error
|
|
1767
1884
|
{
|
|
1768
1885
|
type: "channel",
|
|
1769
|
-
channel_key: chatChannels[0].key,
|
|
1886
|
+
channel_key: params.channelKey ?? chatChannels[0].key,
|
|
1770
1887
|
template: {
|
|
1771
1888
|
markdown_body: params.body
|
|
1772
1889
|
},
|
|
1773
1890
|
ref: params.stepRef ?? generateStepRef("chat")
|
|
1774
1891
|
},
|
|
1775
|
-
|
|
1892
|
+
environment
|
|
1776
1893
|
);
|
|
1777
1894
|
}
|
|
1778
1895
|
});
|
|
@@ -1798,15 +1915,19 @@ var createOrUpdateDelayStepInWorkflow = KnockTool({
|
|
|
1798
1915
|
stepRef: z14.string().optional().describe(
|
|
1799
1916
|
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1800
1917
|
),
|
|
1918
|
+
environment: z14.string().optional().describe(
|
|
1919
|
+
"(string): The environment to operate in. Defaults to `development`."
|
|
1920
|
+
),
|
|
1801
1921
|
delayValue: z14.number().describe("(number): The value of the delay."),
|
|
1802
1922
|
delayUnit: z14.enum(["seconds", "minutes", "hours", "days"]).describe("(enum): The unit of the delay.")
|
|
1803
1923
|
}),
|
|
1804
1924
|
execute: (knockClient, config) => async (params) => {
|
|
1925
|
+
const environment = params.environment ?? config.environment ?? "development";
|
|
1805
1926
|
const workflow2 = await knockClient.workflows.retrieve(params.workflowKey, {
|
|
1806
|
-
environment
|
|
1927
|
+
environment
|
|
1807
1928
|
});
|
|
1808
1929
|
const workflowParams = {
|
|
1809
|
-
environment
|
|
1930
|
+
environment,
|
|
1810
1931
|
workflow: {
|
|
1811
1932
|
...workflow2,
|
|
1812
1933
|
steps: [
|
|
@@ -1857,14 +1978,18 @@ var createOrUpdateBatchStepInWorkflow = KnockTool({
|
|
|
1857
1978
|
stepRef: z14.string().optional().describe(
|
|
1858
1979
|
"(string): The reference of the step to update. If not provided, a new step will be created."
|
|
1859
1980
|
),
|
|
1981
|
+
environment: z14.string().optional().describe(
|
|
1982
|
+
"(string): The environment to operate in. Defaults to `development`."
|
|
1983
|
+
),
|
|
1860
1984
|
batchWindow: z14.object({
|
|
1861
1985
|
value: z14.number().describe("(number): The value of the batch window."),
|
|
1862
1986
|
unit: z14.enum(["seconds", "minutes", "hours", "days"]).describe("(enum): The unit of the batch window.")
|
|
1863
1987
|
})
|
|
1864
1988
|
}),
|
|
1865
1989
|
execute: (knockClient, config) => async (params) => {
|
|
1990
|
+
const environment = params.environment ?? config.environment ?? "development";
|
|
1866
1991
|
const workflow2 = await knockClient.workflows.retrieve(params.workflowKey, {
|
|
1867
|
-
environment
|
|
1992
|
+
environment
|
|
1868
1993
|
});
|
|
1869
1994
|
return await updateWorkflowWithStep(
|
|
1870
1995
|
knockClient,
|
|
@@ -1880,7 +2005,7 @@ var createOrUpdateBatchStepInWorkflow = KnockTool({
|
|
|
1880
2005
|
},
|
|
1881
2006
|
ref: params.stepRef ?? generateStepRef("batch")
|
|
1882
2007
|
},
|
|
1883
|
-
|
|
2008
|
+
environment
|
|
1884
2009
|
);
|
|
1885
2010
|
}
|
|
1886
2011
|
});
|
|
@@ -2133,4 +2258,4 @@ export {
|
|
|
2133
2258
|
getToolsByPermissionsInCategories,
|
|
2134
2259
|
getToolMap
|
|
2135
2260
|
};
|
|
2136
|
-
//# sourceMappingURL=chunk-
|
|
2261
|
+
//# sourceMappingURL=chunk-CRW3ZMHM.js.map
|