@chatbotkit/cli 1.26.1 → 1.26.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/cjs/command/api/blueprint/index.cjs +81 -0
- package/dist/cjs/command/api/blueprint/index.d.ts +8 -0
- package/dist/cjs/command/api/bot/index.cjs +61 -0
- package/dist/cjs/command/api/bot/index.d.ts +6 -0
- package/dist/cjs/command/api/contact/index.cjs +61 -0
- package/dist/cjs/command/api/contact/index.d.ts +6 -0
- package/dist/cjs/command/api/dataset/file/index.cjs +76 -0
- package/dist/cjs/command/api/dataset/file/index.d.ts +7 -0
- package/dist/cjs/command/api/dataset/index.cjs +7 -2
- package/dist/cjs/command/api/dataset/record/index.cjs +83 -0
- package/dist/cjs/command/api/dataset/record/index.d.ts +7 -0
- package/dist/cjs/command/api/file/index.cjs +71 -0
- package/dist/cjs/command/api/file/index.d.ts +7 -0
- package/dist/cjs/command/api/index.cjs +24 -8
- package/dist/cjs/command/api/integration/discord/index.cjs +71 -0
- package/dist/cjs/command/api/integration/discord/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/email/index.cjs +71 -0
- package/dist/cjs/command/api/integration/email/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/extract/index.cjs +61 -0
- package/dist/cjs/command/api/integration/extract/index.d.ts +6 -0
- package/dist/cjs/command/api/integration/index.cjs +44 -0
- package/dist/cjs/command/api/integration/index.d.ts +3 -0
- package/dist/cjs/command/api/integration/instagram/index.cjs +71 -0
- package/dist/cjs/command/api/integration/instagram/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/mcpserver/index.cjs +61 -0
- package/dist/cjs/command/api/integration/mcpserver/index.d.ts +6 -0
- package/dist/cjs/command/api/integration/messenger/index.cjs +71 -0
- package/dist/cjs/command/api/integration/messenger/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/notion/index.cjs +71 -0
- package/dist/cjs/command/api/integration/notion/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/sitemap/index.cjs +71 -0
- package/dist/cjs/command/api/integration/sitemap/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/slack/index.cjs +71 -0
- package/dist/cjs/command/api/integration/slack/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/support/index.cjs +61 -0
- package/dist/cjs/command/api/integration/support/index.d.ts +6 -0
- package/dist/cjs/command/api/integration/telegram/index.cjs +71 -0
- package/dist/cjs/command/api/integration/telegram/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/trigger/index.cjs +71 -0
- package/dist/cjs/command/api/integration/trigger/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/twilio/index.cjs +71 -0
- package/dist/cjs/command/api/integration/twilio/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/whatsapp/index.cjs +71 -0
- package/dist/cjs/command/api/integration/whatsapp/index.d.ts +7 -0
- package/dist/cjs/command/api/integration/widget/index.cjs +71 -0
- package/dist/cjs/command/api/integration/widget/index.d.ts +7 -0
- package/dist/cjs/command/api/memory/index.cjs +79 -0
- package/dist/cjs/command/api/memory/index.d.ts +7 -0
- package/dist/cjs/command/api/secret/index.cjs +81 -0
- package/dist/cjs/command/api/secret/index.d.ts +8 -0
- package/dist/cjs/command/api/skillset/ability/index.cjs +83 -0
- package/dist/cjs/command/api/skillset/ability/index.d.ts +7 -0
- package/dist/cjs/command/api/skillset/index.cjs +5 -2
- package/dist/cjs/command/api/team/index.cjs +42 -0
- package/dist/cjs/command/api/team/index.d.ts +4 -0
- package/dist/cjs/input.cjs +28 -0
- package/dist/cjs/input.d.ts +5 -0
- package/dist/cjs/solution/index.cjs +1 -1
- package/dist/cjs/tools.cjs +5 -186
- package/dist/cjs/tools.d.ts +2 -7
- package/dist/esm/command/api/blueprint/index.d.ts +8 -0
- package/dist/esm/command/api/blueprint/index.js +78 -0
- package/dist/esm/command/api/bot/index.d.ts +6 -0
- package/dist/esm/command/api/bot/index.js +58 -0
- package/dist/esm/command/api/contact/index.d.ts +6 -0
- package/dist/esm/command/api/contact/index.js +58 -0
- package/dist/esm/command/api/dataset/file/index.d.ts +7 -0
- package/dist/esm/command/api/dataset/file/index.js +73 -0
- package/dist/esm/command/api/dataset/index.js +4 -0
- package/dist/esm/command/api/dataset/record/index.d.ts +7 -0
- package/dist/esm/command/api/dataset/record/index.js +80 -0
- package/dist/esm/command/api/file/index.d.ts +7 -0
- package/dist/esm/command/api/file/index.js +68 -0
- package/dist/esm/command/api/index.js +17 -1
- package/dist/esm/command/api/integration/discord/index.d.ts +7 -0
- package/dist/esm/command/api/integration/discord/index.js +68 -0
- package/dist/esm/command/api/integration/email/index.d.ts +7 -0
- package/dist/esm/command/api/integration/email/index.js +68 -0
- package/dist/esm/command/api/integration/extract/index.d.ts +6 -0
- package/dist/esm/command/api/integration/extract/index.js +58 -0
- package/dist/esm/command/api/integration/index.d.ts +3 -0
- package/dist/esm/command/api/integration/index.js +40 -0
- package/dist/esm/command/api/integration/instagram/index.d.ts +7 -0
- package/dist/esm/command/api/integration/instagram/index.js +68 -0
- package/dist/esm/command/api/integration/mcpserver/index.d.ts +6 -0
- package/dist/esm/command/api/integration/mcpserver/index.js +58 -0
- package/dist/esm/command/api/integration/messenger/index.d.ts +7 -0
- package/dist/esm/command/api/integration/messenger/index.js +68 -0
- package/dist/esm/command/api/integration/notion/index.d.ts +7 -0
- package/dist/esm/command/api/integration/notion/index.js +68 -0
- package/dist/esm/command/api/integration/sitemap/index.d.ts +7 -0
- package/dist/esm/command/api/integration/sitemap/index.js +68 -0
- package/dist/esm/command/api/integration/slack/index.d.ts +7 -0
- package/dist/esm/command/api/integration/slack/index.js +68 -0
- package/dist/esm/command/api/integration/support/index.d.ts +6 -0
- package/dist/esm/command/api/integration/support/index.js +58 -0
- package/dist/esm/command/api/integration/telegram/index.d.ts +7 -0
- package/dist/esm/command/api/integration/telegram/index.js +68 -0
- package/dist/esm/command/api/integration/trigger/index.d.ts +7 -0
- package/dist/esm/command/api/integration/trigger/index.js +68 -0
- package/dist/esm/command/api/integration/twilio/index.d.ts +7 -0
- package/dist/esm/command/api/integration/twilio/index.js +68 -0
- package/dist/esm/command/api/integration/whatsapp/index.d.ts +7 -0
- package/dist/esm/command/api/integration/whatsapp/index.js +68 -0
- package/dist/esm/command/api/integration/widget/index.d.ts +7 -0
- package/dist/esm/command/api/integration/widget/index.js +68 -0
- package/dist/esm/command/api/memory/index.d.ts +7 -0
- package/dist/esm/command/api/memory/index.js +76 -0
- package/dist/esm/command/api/secret/index.d.ts +8 -0
- package/dist/esm/command/api/secret/index.js +78 -0
- package/dist/esm/command/api/skillset/ability/index.d.ts +7 -0
- package/dist/esm/command/api/skillset/ability/index.js +80 -0
- package/dist/esm/command/api/skillset/index.js +2 -0
- package/dist/esm/command/api/team/index.d.ts +4 -0
- package/dist/esm/command/api/team/index.js +39 -0
- package/dist/esm/input.d.ts +5 -0
- package/dist/esm/input.js +27 -0
- package/dist/esm/solution/index.d.ts +78 -72
- package/dist/esm/solution/index.js +1 -1
- package/dist/esm/tools.d.ts +2 -7
- package/dist/esm/tools.js +2 -183
- package/package.json +783 -3
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = exports.abilityExport = exports.abilityDelete = exports.abilityFetch = exports.abilityList = void 0;
|
|
4
|
+
const env_js_1 = require("../../../../env.cjs");
|
|
5
|
+
const output_js_1 = require("../../../../output.cjs");
|
|
6
|
+
const index_js_1 = require("@chatbotkit/sdk/skillset/ability/index.js");
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
function getClient() {
|
|
9
|
+
return new index_js_1.SkillsetAbilityClient({
|
|
10
|
+
secret: (0, env_js_1.getSECRET)(),
|
|
11
|
+
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.abilityList = new commander_1.Command()
|
|
15
|
+
.name('list')
|
|
16
|
+
.description('List abilities')
|
|
17
|
+
.option('-s, --stream', 'Stream abilities')
|
|
18
|
+
.argument('<skillsetId>', 'Skillset ID')
|
|
19
|
+
.action(async (skillsetId, options) => {
|
|
20
|
+
const { stream } = options;
|
|
21
|
+
const client = getClient();
|
|
22
|
+
if (stream) {
|
|
23
|
+
for await (const ability of client.list(skillsetId).stream()) {
|
|
24
|
+
(0, output_js_1.print)(ability);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const { items } = await client.list(skillsetId);
|
|
29
|
+
for (const ability of items) {
|
|
30
|
+
(0, output_js_1.print)(ability);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
exports.abilityFetch = new commander_1.Command()
|
|
35
|
+
.name('fetch')
|
|
36
|
+
.description('Fetch ability')
|
|
37
|
+
.argument('<skillsetId>', 'Skillset ID')
|
|
38
|
+
.argument('<abilityId>', 'Ability ID')
|
|
39
|
+
.action(async (skillsetId, abilityId) => {
|
|
40
|
+
const client = getClient();
|
|
41
|
+
const ability = await client.fetch(skillsetId, abilityId);
|
|
42
|
+
(0, output_js_1.print)(ability);
|
|
43
|
+
});
|
|
44
|
+
exports.abilityDelete = new commander_1.Command()
|
|
45
|
+
.name('delete')
|
|
46
|
+
.description('Delete ability')
|
|
47
|
+
.argument('<skillsetId>', 'Skillset ID')
|
|
48
|
+
.argument('<abilityId>', 'Ability ID')
|
|
49
|
+
.action(async (skillsetId, abilityId) => {
|
|
50
|
+
const client = getClient();
|
|
51
|
+
await client.delete(skillsetId, abilityId);
|
|
52
|
+
});
|
|
53
|
+
exports.abilityExport = new commander_1.Command()
|
|
54
|
+
.name('export')
|
|
55
|
+
.description('Export abilities')
|
|
56
|
+
.option('-s, --stream', 'Stream exports')
|
|
57
|
+
.argument('<skillsetId>', 'Skillset ID')
|
|
58
|
+
.action(async (skillsetId, options) => {
|
|
59
|
+
const { stream } = options;
|
|
60
|
+
const client = getClient();
|
|
61
|
+
if (stream) {
|
|
62
|
+
for await (const ability of client.export(skillsetId).stream()) {
|
|
63
|
+
(0, output_js_1.print)(ability);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const result = await client.export(skillsetId);
|
|
68
|
+
(0, output_js_1.print)(result);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const commands = {
|
|
72
|
+
list: exports.abilityList,
|
|
73
|
+
fetch: exports.abilityFetch,
|
|
74
|
+
delete: exports.abilityDelete,
|
|
75
|
+
export: exports.abilityExport,
|
|
76
|
+
};
|
|
77
|
+
exports.command = new commander_1.Command()
|
|
78
|
+
.name('ability')
|
|
79
|
+
.description('Ability tools for ChatBotKit');
|
|
80
|
+
for (const cmd of Object.values(commands)) {
|
|
81
|
+
exports.command.addCommand(cmd);
|
|
82
|
+
}
|
|
83
|
+
exports.default = exports.command;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.command = exports.skillsetDelete = exports.skillsetFetch = exports.skillsetList = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const env_js_1 = require("../../../env.cjs");
|
|
5
6
|
const output_js_1 = require("../../../output.cjs");
|
|
6
|
-
const index_js_1 = require("
|
|
7
|
+
const index_js_1 = tslib_1.__importDefault(require("./ability/index.cjs"));
|
|
8
|
+
const index_js_2 = require("@chatbotkit/sdk/skillset/index.js");
|
|
7
9
|
const commander_1 = require("commander");
|
|
8
10
|
function getClient() {
|
|
9
|
-
return new
|
|
11
|
+
return new index_js_2.SkillsetClient({
|
|
10
12
|
secret: (0, env_js_1.getSECRET)(),
|
|
11
13
|
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
12
14
|
});
|
|
@@ -51,6 +53,7 @@ const commands = {
|
|
|
51
53
|
list: exports.skillsetList,
|
|
52
54
|
fetch: exports.skillsetFetch,
|
|
53
55
|
delete: exports.skillsetDelete,
|
|
56
|
+
ability: index_js_1.default,
|
|
54
57
|
};
|
|
55
58
|
exports.command = new commander_1.Command()
|
|
56
59
|
.name('skillset')
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = exports.teamList = void 0;
|
|
4
|
+
const env_js_1 = require("../../../env.cjs");
|
|
5
|
+
const output_js_1 = require("../../../output.cjs");
|
|
6
|
+
const index_js_1 = require("@chatbotkit/sdk/team/index.js");
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
function getClient() {
|
|
9
|
+
return new index_js_1.TeamClient({
|
|
10
|
+
secret: (0, env_js_1.getSECRET)(),
|
|
11
|
+
runAsUserId: (0, env_js_1.getRUNAS_USERID)(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.teamList = new commander_1.Command()
|
|
15
|
+
.name('list')
|
|
16
|
+
.description('List teams')
|
|
17
|
+
.option('-s, --stream', 'Stream teams')
|
|
18
|
+
.action(async (str, options) => {
|
|
19
|
+
const { stream } = options;
|
|
20
|
+
const client = getClient();
|
|
21
|
+
if (stream) {
|
|
22
|
+
for await (const team of client.list().stream()) {
|
|
23
|
+
(0, output_js_1.print)(team);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const { items } = await client.list();
|
|
28
|
+
for (const team of items) {
|
|
29
|
+
(0, output_js_1.print)(team);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const commands = {
|
|
34
|
+
list: exports.teamList,
|
|
35
|
+
};
|
|
36
|
+
exports.command = new commander_1.Command()
|
|
37
|
+
.name('team')
|
|
38
|
+
.description('Team tools for ChatBotKit');
|
|
39
|
+
for (const cmd of Object.values(commands)) {
|
|
40
|
+
exports.command.addCommand(cmd);
|
|
41
|
+
}
|
|
42
|
+
exports.default = exports.command;
|
package/dist/cjs/input.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.confirm = confirm;
|
|
4
4
|
exports.prompt = prompt;
|
|
5
|
+
exports.select = select;
|
|
5
6
|
const tslib_1 = require("tslib");
|
|
6
7
|
const readline_1 = tslib_1.__importDefault(require("readline"));
|
|
7
8
|
async function confirm(question) {
|
|
@@ -28,3 +29,30 @@ async function prompt(question) {
|
|
|
28
29
|
});
|
|
29
30
|
});
|
|
30
31
|
}
|
|
32
|
+
async function select(question, options) {
|
|
33
|
+
const rl = readline_1.default.createInterface({
|
|
34
|
+
input: process.stdin,
|
|
35
|
+
output: process.stdout,
|
|
36
|
+
});
|
|
37
|
+
try {
|
|
38
|
+
while (true) {
|
|
39
|
+
console.log(question);
|
|
40
|
+
options.forEach((option, index) => {
|
|
41
|
+
console.log(` ${index + 1}) ${option.label}`);
|
|
42
|
+
});
|
|
43
|
+
const answer = await new Promise((resolve) => {
|
|
44
|
+
rl.question('Enter your choice (number): ', (input) => {
|
|
45
|
+
resolve(input);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
const index = parseInt((answer), 10) - 1;
|
|
49
|
+
if (index >= 0 && index < options.length) {
|
|
50
|
+
return options[index].value;
|
|
51
|
+
}
|
|
52
|
+
console.log('Invalid choice. Please try again.\n');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
rl.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
package/dist/cjs/input.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export function confirm(question: string): Promise<boolean>;
|
|
2
2
|
export function prompt(question: string): Promise<string>;
|
|
3
|
+
export function select(question: string, options: SelectOption[]): Promise<string>;
|
|
4
|
+
export type SelectOption = {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
@@ -344,7 +344,7 @@ exports.ExtractIntegrationResourceConfigSchema = exports.BasicResourceConfigSche
|
|
|
344
344
|
botId: zod_1.z.string().optional(),
|
|
345
345
|
schema: zod_1.z.record(zod_1.z.unknown()).optional(),
|
|
346
346
|
request: zod_1.z.string().optional(),
|
|
347
|
-
|
|
347
|
+
model: zod_1.z.string().optional(),
|
|
348
348
|
}),
|
|
349
349
|
});
|
|
350
350
|
exports.McpServerIntegrationResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
|
package/dist/cjs/tools.cjs
CHANGED
|
@@ -3,195 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tools = void 0;
|
|
4
4
|
exports.getTools = getTools;
|
|
5
5
|
exports.getToolNames = getToolNames;
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const util_1 = require("util");
|
|
9
|
-
const zod_1 = require("zod");
|
|
10
|
-
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
11
|
-
exports.tools = {
|
|
12
|
-
read: {
|
|
13
|
-
description: 'Read the contents of a file',
|
|
14
|
-
default: true,
|
|
15
|
-
input: zod_1.z.object({
|
|
16
|
-
path: zod_1.z.string().describe('The file path to read'),
|
|
17
|
-
}),
|
|
18
|
-
handler: async (input) => {
|
|
19
|
-
try {
|
|
20
|
-
const content = await (0, promises_1.readFile)(input.path, 'utf-8');
|
|
21
|
-
return { success: true, content };
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
return {
|
|
25
|
-
success: false,
|
|
26
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
write: {
|
|
32
|
-
description: 'Write content to a file',
|
|
33
|
-
default: true,
|
|
34
|
-
input: zod_1.z.object({
|
|
35
|
-
path: zod_1.z.string().describe('The file path to write to'),
|
|
36
|
-
content: zod_1.z.string().describe('The content to write'),
|
|
37
|
-
}),
|
|
38
|
-
handler: async (input) => {
|
|
39
|
-
try {
|
|
40
|
-
await (0, promises_1.writeFile)(input.path, input.content, 'utf-8');
|
|
41
|
-
return { success: true };
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
return {
|
|
45
|
-
success: false,
|
|
46
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
edit: {
|
|
52
|
-
description: 'Edit a file by replacing an exact string occurrence with a new string. Only one occurrence must exist.',
|
|
53
|
-
default: true,
|
|
54
|
-
input: zod_1.z.object({
|
|
55
|
-
path: zod_1.z.string().describe('The file path to edit'),
|
|
56
|
-
oldString: zod_1.z
|
|
57
|
-
.string()
|
|
58
|
-
.describe('The exact string to find and replace (must match exactly)'),
|
|
59
|
-
newString: zod_1.z.string().describe('The new string to replace with'),
|
|
60
|
-
}),
|
|
61
|
-
handler: async (input) => {
|
|
62
|
-
try {
|
|
63
|
-
const content = await (0, promises_1.readFile)(input.path, 'utf-8');
|
|
64
|
-
const occurrences = content.split(input.oldString).length - 1;
|
|
65
|
-
if (occurrences === 0) {
|
|
66
|
-
return {
|
|
67
|
-
success: false,
|
|
68
|
-
error: 'String not found in file',
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
if (occurrences > 1) {
|
|
72
|
-
return {
|
|
73
|
-
success: false,
|
|
74
|
-
error: `Multiple occurrences found (${occurrences}). The old string must match exactly one location.`,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
const newContent = content.replace(input.oldString, input.newString);
|
|
78
|
-
await (0, promises_1.writeFile)(input.path, newContent, 'utf-8');
|
|
79
|
-
const oldPreview = input.oldString.length > 100
|
|
80
|
-
? input.oldString.substring(0, 100) + '...'
|
|
81
|
-
: input.oldString;
|
|
82
|
-
const newPreview = input.newString.length > 100
|
|
83
|
-
? input.newString.substring(0, 100) + '...'
|
|
84
|
-
: input.newString;
|
|
85
|
-
return {
|
|
86
|
-
success: true,
|
|
87
|
-
message: `Successfully replaced:\n OLD: ${oldPreview}\n NEW: ${newPreview}`,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
return {
|
|
92
|
-
success: false,
|
|
93
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
find: {
|
|
99
|
-
description: 'Search for files matching a pattern',
|
|
100
|
-
default: true,
|
|
101
|
-
input: zod_1.z.object({
|
|
102
|
-
pattern: zod_1.z.string().describe('The glob pattern to search for'),
|
|
103
|
-
directory: zod_1.z
|
|
104
|
-
.string()
|
|
105
|
-
.optional()
|
|
106
|
-
.describe('The directory to search in (defaults to current)'),
|
|
107
|
-
}),
|
|
108
|
-
handler: async (input) => {
|
|
109
|
-
try {
|
|
110
|
-
const dir = input.directory || '.';
|
|
111
|
-
const { stdout } = await execAsync(`find ${dir} -name "${input.pattern}"`);
|
|
112
|
-
const files = stdout.trim().split('\n').filter(Boolean);
|
|
113
|
-
return { success: true, files };
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
return {
|
|
117
|
-
success: false,
|
|
118
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
exec: {
|
|
124
|
-
description: 'Execute a shell command (non-interactive only). Commands timeout after the specified duration (default 30 seconds). Use only for commands that run and exit automatically.',
|
|
125
|
-
default: true,
|
|
126
|
-
input: zod_1.z.object({
|
|
127
|
-
command: zod_1.z.string().describe('The command to execute'),
|
|
128
|
-
timeout: zod_1.z
|
|
129
|
-
.number()
|
|
130
|
-
.default(30)
|
|
131
|
-
.describe('Timeout in seconds. The command will be killed if it runs longer than this.'),
|
|
132
|
-
}),
|
|
133
|
-
handler: async (input) => {
|
|
134
|
-
const timeoutMs = input.timeout * 1000;
|
|
135
|
-
return new Promise((resolve) => {
|
|
136
|
-
const childProcess = (0, child_process_1.spawn)('sh', ['-c', input.command], {
|
|
137
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
138
|
-
timeout: timeoutMs,
|
|
139
|
-
});
|
|
140
|
-
let stdout = '';
|
|
141
|
-
let stderr = '';
|
|
142
|
-
let timedOut = false;
|
|
143
|
-
childProcess.stdout.on('data', (data) => {
|
|
144
|
-
stdout += data.toString();
|
|
145
|
-
});
|
|
146
|
-
childProcess.stderr.on('data', (data) => {
|
|
147
|
-
stderr += data.toString();
|
|
148
|
-
});
|
|
149
|
-
childProcess.on('close', (code) => {
|
|
150
|
-
if (timedOut) {
|
|
151
|
-
resolve({
|
|
152
|
-
success: false,
|
|
153
|
-
error: `Command timed out after ${timeoutMs / 1000} seconds. This may indicate an interactive command.`,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
else if (code === 0) {
|
|
157
|
-
resolve({ success: true, stdout, stderr });
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
resolve({
|
|
161
|
-
success: false,
|
|
162
|
-
error: `Command exited with code ${code}`,
|
|
163
|
-
stdout,
|
|
164
|
-
stderr,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
childProcess.on('error', (error) => {
|
|
169
|
-
resolve({
|
|
170
|
-
success: false,
|
|
171
|
-
error: error.message,
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
setTimeout(() => {
|
|
175
|
-
if (!childProcess.killed) {
|
|
176
|
-
timedOut = true;
|
|
177
|
-
childProcess.kill('SIGTERM');
|
|
178
|
-
setTimeout(() => {
|
|
179
|
-
if (!childProcess.killed) {
|
|
180
|
-
childProcess.kill('SIGKILL');
|
|
181
|
-
}
|
|
182
|
-
}, 2000);
|
|
183
|
-
}
|
|
184
|
-
}, timeoutMs);
|
|
185
|
-
});
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
};
|
|
6
|
+
const agent_1 = require("@chatbotkit/agent");
|
|
7
|
+
Object.defineProperty(exports, "tools", { enumerable: true, get: function () { return agent_1.tools; } });
|
|
189
8
|
function getTools(selectedTools) {
|
|
190
9
|
if (!selectedTools || selectedTools.length === 0) {
|
|
191
|
-
return Object.fromEntries(Object.entries(
|
|
10
|
+
return Object.fromEntries(Object.entries(agent_1.tools).filter(([, tool]) => tool.default));
|
|
192
11
|
}
|
|
193
|
-
return Object.fromEntries(Object.entries(
|
|
12
|
+
return Object.fromEntries(Object.entries(agent_1.tools).filter(([name]) => selectedTools.includes(name)));
|
|
194
13
|
}
|
|
195
14
|
function getToolNames() {
|
|
196
|
-
return Object.keys(
|
|
15
|
+
return Object.keys(agent_1.tools);
|
|
197
16
|
}
|
package/dist/cjs/tools.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
export function getTools(selectedTools?: Array<keyof typeof tools>): typeof tools;
|
|
2
2
|
export function getToolNames(): Array<keyof typeof tools>;
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
input: z.ZodObject<any>;
|
|
6
|
-
handler: (input: any) => Promise<any>;
|
|
7
|
-
default?: boolean;
|
|
8
|
-
}>;
|
|
9
|
-
import { z } from 'zod';
|
|
3
|
+
export { tools };
|
|
4
|
+
import { tools } from '@chatbotkit/agent';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const blueprintList: Command;
|
|
2
|
+
export const blueprintFetch: Command;
|
|
3
|
+
export const blueprintDelete: Command;
|
|
4
|
+
export const blueprintClone: Command;
|
|
5
|
+
export const blueprintListResources: Command;
|
|
6
|
+
export const command: Command;
|
|
7
|
+
export default command;
|
|
8
|
+
import { Command } from 'commander';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getRUNAS_USERID, getSECRET } from '../../../env.js';
|
|
2
|
+
import { print } from '../../../output.js';
|
|
3
|
+
import { BlueprintClient } from '@chatbotkit/sdk/blueprint/index.js';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
function getClient() {
|
|
6
|
+
return new BlueprintClient({
|
|
7
|
+
secret: getSECRET(),
|
|
8
|
+
runAsUserId: getRUNAS_USERID(),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export const blueprintList = new Command()
|
|
12
|
+
.name('list')
|
|
13
|
+
.description('List blueprints')
|
|
14
|
+
.option('-s, --stream', 'Stream blueprints')
|
|
15
|
+
.action(async (str, options) => {
|
|
16
|
+
const { stream } = options;
|
|
17
|
+
const client = getClient();
|
|
18
|
+
if (stream) {
|
|
19
|
+
for await (const blueprint of client.list().stream()) {
|
|
20
|
+
print(blueprint);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const { items } = await client.list();
|
|
25
|
+
for (const blueprint of items) {
|
|
26
|
+
print(blueprint);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export const blueprintFetch = new Command()
|
|
31
|
+
.name('fetch')
|
|
32
|
+
.description('Fetch blueprint')
|
|
33
|
+
.argument('<blueprintId>', 'Blueprint ID')
|
|
34
|
+
.action(async (blueprintId) => {
|
|
35
|
+
const client = getClient();
|
|
36
|
+
const blueprint = await client.fetch(blueprintId);
|
|
37
|
+
print(blueprint);
|
|
38
|
+
});
|
|
39
|
+
export const blueprintDelete = new Command()
|
|
40
|
+
.name('delete')
|
|
41
|
+
.description('Delete blueprint')
|
|
42
|
+
.argument('<blueprintId>', 'Blueprint ID')
|
|
43
|
+
.action(async (blueprintId) => {
|
|
44
|
+
const client = getClient();
|
|
45
|
+
await client.delete(blueprintId);
|
|
46
|
+
});
|
|
47
|
+
export const blueprintClone = new Command()
|
|
48
|
+
.name('clone')
|
|
49
|
+
.description('Clone blueprint')
|
|
50
|
+
.argument('<blueprintId>', 'Blueprint ID')
|
|
51
|
+
.action(async (blueprintId) => {
|
|
52
|
+
const client = getClient();
|
|
53
|
+
const result = await client.clone(blueprintId);
|
|
54
|
+
print(result);
|
|
55
|
+
});
|
|
56
|
+
export const blueprintListResources = new Command()
|
|
57
|
+
.name('list-resources')
|
|
58
|
+
.description('List blueprint resources')
|
|
59
|
+
.argument('<blueprintId>', 'Blueprint ID')
|
|
60
|
+
.action(async (blueprintId) => {
|
|
61
|
+
const client = getClient();
|
|
62
|
+
const result = await client.listResources(blueprintId);
|
|
63
|
+
print(result);
|
|
64
|
+
});
|
|
65
|
+
const commands = {
|
|
66
|
+
list: blueprintList,
|
|
67
|
+
fetch: blueprintFetch,
|
|
68
|
+
delete: blueprintDelete,
|
|
69
|
+
clone: blueprintClone,
|
|
70
|
+
listResources: blueprintListResources,
|
|
71
|
+
};
|
|
72
|
+
export const command = new Command()
|
|
73
|
+
.name('blueprint')
|
|
74
|
+
.description('Blueprint tools for ChatBotKit');
|
|
75
|
+
for (const cmd of Object.values(commands)) {
|
|
76
|
+
command.addCommand(cmd);
|
|
77
|
+
}
|
|
78
|
+
export default command;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getRUNAS_USERID, getSECRET } from '../../../env.js';
|
|
2
|
+
import { print } from '../../../output.js';
|
|
3
|
+
import { BotClient } from '@chatbotkit/sdk/bot/index.js';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
function getClient() {
|
|
6
|
+
return new BotClient({
|
|
7
|
+
secret: getSECRET(),
|
|
8
|
+
runAsUserId: getRUNAS_USERID(),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export const botList = new Command()
|
|
12
|
+
.name('list')
|
|
13
|
+
.description('List bots')
|
|
14
|
+
.option('-s, --stream', 'Stream bots')
|
|
15
|
+
.action(async (str, options) => {
|
|
16
|
+
const { stream } = options;
|
|
17
|
+
const client = getClient();
|
|
18
|
+
if (stream) {
|
|
19
|
+
for await (const bot of client.list().stream()) {
|
|
20
|
+
print(bot);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const { items } = await client.list();
|
|
25
|
+
for (const bot of items) {
|
|
26
|
+
print(bot);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export const botFetch = new Command()
|
|
31
|
+
.name('fetch')
|
|
32
|
+
.description('Fetch bot')
|
|
33
|
+
.argument('<botId>', 'Bot ID')
|
|
34
|
+
.action(async (botId) => {
|
|
35
|
+
const client = getClient();
|
|
36
|
+
const bot = await client.fetch(botId);
|
|
37
|
+
print(bot);
|
|
38
|
+
});
|
|
39
|
+
export const botDelete = new Command()
|
|
40
|
+
.name('delete')
|
|
41
|
+
.description('Delete bot')
|
|
42
|
+
.argument('<botId>', 'Bot ID')
|
|
43
|
+
.action(async (botId) => {
|
|
44
|
+
const client = getClient();
|
|
45
|
+
await client.delete(botId);
|
|
46
|
+
});
|
|
47
|
+
const commands = {
|
|
48
|
+
list: botList,
|
|
49
|
+
fetch: botFetch,
|
|
50
|
+
delete: botDelete,
|
|
51
|
+
};
|
|
52
|
+
export const command = new Command()
|
|
53
|
+
.name('bot')
|
|
54
|
+
.description('Bot tools for ChatBotKit');
|
|
55
|
+
for (const cmd of Object.values(commands)) {
|
|
56
|
+
command.addCommand(cmd);
|
|
57
|
+
}
|
|
58
|
+
export default command;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getRUNAS_USERID, getSECRET } from '../../../env.js';
|
|
2
|
+
import { print } from '../../../output.js';
|
|
3
|
+
import { ContactClient } from '@chatbotkit/sdk/contact/index.js';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
function getClient() {
|
|
6
|
+
return new ContactClient({
|
|
7
|
+
secret: getSECRET(),
|
|
8
|
+
runAsUserId: getRUNAS_USERID(),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export const contactList = new Command()
|
|
12
|
+
.name('list')
|
|
13
|
+
.description('List contacts')
|
|
14
|
+
.option('-s, --stream', 'Stream contacts')
|
|
15
|
+
.action(async (str, options) => {
|
|
16
|
+
const { stream } = options;
|
|
17
|
+
const client = getClient();
|
|
18
|
+
if (stream) {
|
|
19
|
+
for await (const contact of client.list().stream()) {
|
|
20
|
+
print(contact);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const { items } = await client.list();
|
|
25
|
+
for (const contact of items) {
|
|
26
|
+
print(contact);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export const contactFetch = new Command()
|
|
31
|
+
.name('fetch')
|
|
32
|
+
.description('Fetch contact')
|
|
33
|
+
.argument('<contactId>', 'Contact ID')
|
|
34
|
+
.action(async (contactId) => {
|
|
35
|
+
const client = getClient();
|
|
36
|
+
const contact = await client.fetch(contactId);
|
|
37
|
+
print(contact);
|
|
38
|
+
});
|
|
39
|
+
export const contactDelete = new Command()
|
|
40
|
+
.name('delete')
|
|
41
|
+
.description('Delete contact')
|
|
42
|
+
.argument('<contactId>', 'Contact ID')
|
|
43
|
+
.action(async (contactId) => {
|
|
44
|
+
const client = getClient();
|
|
45
|
+
await client.delete(contactId);
|
|
46
|
+
});
|
|
47
|
+
const commands = {
|
|
48
|
+
list: contactList,
|
|
49
|
+
fetch: contactFetch,
|
|
50
|
+
delete: contactDelete,
|
|
51
|
+
};
|
|
52
|
+
export const command = new Command()
|
|
53
|
+
.name('contact')
|
|
54
|
+
.description('Contact tools for ChatBotKit');
|
|
55
|
+
for (const cmd of Object.values(commands)) {
|
|
56
|
+
command.addCommand(cmd);
|
|
57
|
+
}
|
|
58
|
+
export default command;
|