@chatbotkit/cli 1.26.2 → 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/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 +74 -68
- package/dist/esm/solution/index.js +1 -1
- package/package.json +804 -26
|
@@ -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({
|
|
@@ -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;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getRUNAS_USERID, getSECRET } from '../../../../env.js';
|
|
2
|
+
import { print } from '../../../../output.js';
|
|
3
|
+
import { DatasetFileClient } from '@chatbotkit/sdk/dataset/file/index.js';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
function getClient() {
|
|
6
|
+
return new DatasetFileClient({
|
|
7
|
+
secret: getSECRET(),
|
|
8
|
+
runAsUserId: getRUNAS_USERID(),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export const fileList = new Command()
|
|
12
|
+
.name('list')
|
|
13
|
+
.description('List files')
|
|
14
|
+
.option('-s, --stream', 'Stream files')
|
|
15
|
+
.argument('<datasetId>', 'Dataset ID')
|
|
16
|
+
.action(async (datasetId, options) => {
|
|
17
|
+
const { stream } = options;
|
|
18
|
+
const client = getClient();
|
|
19
|
+
if (stream) {
|
|
20
|
+
for await (const file of client.list(datasetId).stream()) {
|
|
21
|
+
print(file);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const { items } = await client.list(datasetId);
|
|
26
|
+
for (const file of items) {
|
|
27
|
+
print(file);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export const fileAttach = new Command()
|
|
32
|
+
.name('attach')
|
|
33
|
+
.description('Attach file to dataset')
|
|
34
|
+
.argument('<datasetId>', 'Dataset ID')
|
|
35
|
+
.argument('<fileId>', 'File ID')
|
|
36
|
+
.action(async (datasetId, fileId) => {
|
|
37
|
+
const client = getClient();
|
|
38
|
+
const result = await client.attach(datasetId, fileId, {});
|
|
39
|
+
print(result);
|
|
40
|
+
});
|
|
41
|
+
export const fileDetach = new Command()
|
|
42
|
+
.name('detach')
|
|
43
|
+
.description('Detach file from dataset')
|
|
44
|
+
.argument('<datasetId>', 'Dataset ID')
|
|
45
|
+
.argument('<fileId>', 'File ID')
|
|
46
|
+
.action(async (datasetId, fileId) => {
|
|
47
|
+
const client = getClient();
|
|
48
|
+
const result = await client.detach(datasetId, fileId, {});
|
|
49
|
+
print(result);
|
|
50
|
+
});
|
|
51
|
+
export const fileSync = new Command()
|
|
52
|
+
.name('sync')
|
|
53
|
+
.description('Sync file')
|
|
54
|
+
.argument('<datasetId>', 'Dataset ID')
|
|
55
|
+
.argument('<fileId>', 'File ID')
|
|
56
|
+
.action(async (datasetId, fileId) => {
|
|
57
|
+
const client = getClient();
|
|
58
|
+
const result = await client.sync(datasetId, fileId, {});
|
|
59
|
+
print(result);
|
|
60
|
+
});
|
|
61
|
+
const commands = {
|
|
62
|
+
list: fileList,
|
|
63
|
+
attach: fileAttach,
|
|
64
|
+
detach: fileDetach,
|
|
65
|
+
sync: fileSync,
|
|
66
|
+
};
|
|
67
|
+
export const command = new Command()
|
|
68
|
+
.name('file')
|
|
69
|
+
.description('File tools for ChatBotKit');
|
|
70
|
+
for (const cmd of Object.values(commands)) {
|
|
71
|
+
command.addCommand(cmd);
|
|
72
|
+
}
|
|
73
|
+
export default command;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { getRUNAS_USERID, getSECRET } from '../../../env.js';
|
|
2
2
|
import { print } from '../../../output.js';
|
|
3
|
+
import file from './file/index.js';
|
|
4
|
+
import record from './record/index.js';
|
|
3
5
|
import { DatasetClient } from '@chatbotkit/sdk/dataset/index.js';
|
|
4
6
|
import { Command } from 'commander';
|
|
5
7
|
function getClient() {
|
|
@@ -48,6 +50,8 @@ const commands = {
|
|
|
48
50
|
list: datasetList,
|
|
49
51
|
fetch: datasetFetch,
|
|
50
52
|
delete: datasetDelete,
|
|
53
|
+
file,
|
|
54
|
+
record,
|
|
51
55
|
};
|
|
52
56
|
export const command = new Command()
|
|
53
57
|
.name('dataset')
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getRUNAS_USERID, getSECRET } from '../../../../env.js';
|
|
2
|
+
import { print } from '../../../../output.js';
|
|
3
|
+
import { DatasetRecordClient } from '@chatbotkit/sdk/dataset/record/index.js';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
function getClient() {
|
|
6
|
+
return new DatasetRecordClient({
|
|
7
|
+
secret: getSECRET(),
|
|
8
|
+
runAsUserId: getRUNAS_USERID(),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export const recordList = new Command()
|
|
12
|
+
.name('list')
|
|
13
|
+
.description('List records')
|
|
14
|
+
.option('-s, --stream', 'Stream records')
|
|
15
|
+
.argument('<datasetId>', 'Dataset ID')
|
|
16
|
+
.action(async (datasetId, options) => {
|
|
17
|
+
const { stream } = options;
|
|
18
|
+
const client = getClient();
|
|
19
|
+
if (stream) {
|
|
20
|
+
for await (const record of client.list(datasetId).stream()) {
|
|
21
|
+
print(record);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const { items } = await client.list(datasetId);
|
|
26
|
+
for (const record of items) {
|
|
27
|
+
print(record);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export const recordFetch = new Command()
|
|
32
|
+
.name('fetch')
|
|
33
|
+
.description('Fetch record')
|
|
34
|
+
.argument('<datasetId>', 'Dataset ID')
|
|
35
|
+
.argument('<recordId>', 'Record ID')
|
|
36
|
+
.action(async (datasetId, recordId) => {
|
|
37
|
+
const client = getClient();
|
|
38
|
+
const record = await client.fetch(datasetId, recordId);
|
|
39
|
+
print(record);
|
|
40
|
+
});
|
|
41
|
+
export const recordDelete = new Command()
|
|
42
|
+
.name('delete')
|
|
43
|
+
.description('Delete record')
|
|
44
|
+
.argument('<datasetId>', 'Dataset ID')
|
|
45
|
+
.argument('<recordId>', 'Record ID')
|
|
46
|
+
.action(async (datasetId, recordId) => {
|
|
47
|
+
const client = getClient();
|
|
48
|
+
await client.delete(datasetId, recordId);
|
|
49
|
+
});
|
|
50
|
+
export const recordExport = new Command()
|
|
51
|
+
.name('export')
|
|
52
|
+
.description('Export records')
|
|
53
|
+
.option('-s, --stream', 'Stream exports')
|
|
54
|
+
.argument('<datasetId>', 'Dataset ID')
|
|
55
|
+
.action(async (datasetId, options) => {
|
|
56
|
+
const { stream } = options;
|
|
57
|
+
const client = getClient();
|
|
58
|
+
if (stream) {
|
|
59
|
+
for await (const record of client.export(datasetId).stream()) {
|
|
60
|
+
print(record);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const result = await client.export(datasetId);
|
|
65
|
+
print(result);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const commands = {
|
|
69
|
+
list: recordList,
|
|
70
|
+
fetch: recordFetch,
|
|
71
|
+
delete: recordDelete,
|
|
72
|
+
export: recordExport,
|
|
73
|
+
};
|
|
74
|
+
export const command = new Command()
|
|
75
|
+
.name('record')
|
|
76
|
+
.description('Record tools for ChatBotKit');
|
|
77
|
+
for (const cmd of Object.values(commands)) {
|
|
78
|
+
command.addCommand(cmd);
|
|
79
|
+
}
|
|
80
|
+
export default command;
|