@chatbotkit/cli 1.26.2 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/cjs/color.cjs +11 -1
  2. package/dist/cjs/color.d.ts +4 -0
  3. package/dist/cjs/command/api/blueprint/index.cjs +81 -0
  4. package/dist/cjs/command/api/blueprint/index.d.ts +8 -0
  5. package/dist/cjs/command/api/bot/index.cjs +61 -0
  6. package/dist/cjs/command/api/bot/index.d.ts +6 -0
  7. package/dist/cjs/command/api/contact/index.cjs +61 -0
  8. package/dist/cjs/command/api/contact/index.d.ts +6 -0
  9. package/dist/cjs/command/api/dataset/file/index.cjs +76 -0
  10. package/dist/cjs/command/api/dataset/file/index.d.ts +7 -0
  11. package/dist/cjs/command/api/dataset/index.cjs +7 -2
  12. package/dist/cjs/command/api/dataset/record/index.cjs +83 -0
  13. package/dist/cjs/command/api/dataset/record/index.d.ts +7 -0
  14. package/dist/cjs/command/api/file/index.cjs +71 -0
  15. package/dist/cjs/command/api/file/index.d.ts +7 -0
  16. package/dist/cjs/command/api/index.cjs +24 -8
  17. package/dist/cjs/command/api/integration/discord/index.cjs +71 -0
  18. package/dist/cjs/command/api/integration/discord/index.d.ts +7 -0
  19. package/dist/cjs/command/api/integration/email/index.cjs +71 -0
  20. package/dist/cjs/command/api/integration/email/index.d.ts +7 -0
  21. package/dist/cjs/command/api/integration/extract/index.cjs +61 -0
  22. package/dist/cjs/command/api/integration/extract/index.d.ts +6 -0
  23. package/dist/cjs/command/api/integration/index.cjs +44 -0
  24. package/dist/cjs/command/api/integration/index.d.ts +3 -0
  25. package/dist/cjs/command/api/integration/instagram/index.cjs +71 -0
  26. package/dist/cjs/command/api/integration/instagram/index.d.ts +7 -0
  27. package/dist/cjs/command/api/integration/mcpserver/index.cjs +61 -0
  28. package/dist/cjs/command/api/integration/mcpserver/index.d.ts +6 -0
  29. package/dist/cjs/command/api/integration/messenger/index.cjs +71 -0
  30. package/dist/cjs/command/api/integration/messenger/index.d.ts +7 -0
  31. package/dist/cjs/command/api/integration/notion/index.cjs +71 -0
  32. package/dist/cjs/command/api/integration/notion/index.d.ts +7 -0
  33. package/dist/cjs/command/api/integration/sitemap/index.cjs +71 -0
  34. package/dist/cjs/command/api/integration/sitemap/index.d.ts +7 -0
  35. package/dist/cjs/command/api/integration/slack/index.cjs +71 -0
  36. package/dist/cjs/command/api/integration/slack/index.d.ts +7 -0
  37. package/dist/cjs/command/api/integration/support/index.cjs +61 -0
  38. package/dist/cjs/command/api/integration/support/index.d.ts +6 -0
  39. package/dist/cjs/command/api/integration/telegram/index.cjs +71 -0
  40. package/dist/cjs/command/api/integration/telegram/index.d.ts +7 -0
  41. package/dist/cjs/command/api/integration/trigger/index.cjs +71 -0
  42. package/dist/cjs/command/api/integration/trigger/index.d.ts +7 -0
  43. package/dist/cjs/command/api/integration/twilio/index.cjs +71 -0
  44. package/dist/cjs/command/api/integration/twilio/index.d.ts +7 -0
  45. package/dist/cjs/command/api/integration/whatsapp/index.cjs +71 -0
  46. package/dist/cjs/command/api/integration/whatsapp/index.d.ts +7 -0
  47. package/dist/cjs/command/api/integration/widget/index.cjs +71 -0
  48. package/dist/cjs/command/api/integration/widget/index.d.ts +7 -0
  49. package/dist/cjs/command/api/memory/index.cjs +79 -0
  50. package/dist/cjs/command/api/memory/index.d.ts +7 -0
  51. package/dist/cjs/command/api/secret/index.cjs +81 -0
  52. package/dist/cjs/command/api/secret/index.d.ts +8 -0
  53. package/dist/cjs/command/api/skillset/ability/index.cjs +83 -0
  54. package/dist/cjs/command/api/skillset/ability/index.d.ts +7 -0
  55. package/dist/cjs/command/api/skillset/index.cjs +5 -2
  56. package/dist/cjs/command/api/team/index.cjs +42 -0
  57. package/dist/cjs/command/api/team/index.d.ts +4 -0
  58. package/dist/cjs/command/run/index.cjs +83 -0
  59. package/dist/cjs/command/run/index.d.ts +3 -0
  60. package/dist/cjs/index.cjs +7 -1
  61. package/dist/cjs/index.d.ts +4 -0
  62. package/dist/cjs/input.cjs +28 -0
  63. package/dist/cjs/input.d.ts +5 -0
  64. package/dist/cjs/loader/hooks.cjs +82 -0
  65. package/dist/cjs/loader/hooks.d.ts +4 -0
  66. package/dist/cjs/loader/index.cjs +8 -0
  67. package/dist/cjs/loader/index.d.ts +1 -0
  68. package/dist/cjs/solution/index.cjs +7 -1
  69. package/dist/esm/color.d.ts +4 -0
  70. package/dist/esm/color.js +8 -0
  71. package/dist/esm/command/api/blueprint/index.d.ts +8 -0
  72. package/dist/esm/command/api/blueprint/index.js +78 -0
  73. package/dist/esm/command/api/bot/index.d.ts +6 -0
  74. package/dist/esm/command/api/bot/index.js +58 -0
  75. package/dist/esm/command/api/contact/index.d.ts +6 -0
  76. package/dist/esm/command/api/contact/index.js +58 -0
  77. package/dist/esm/command/api/dataset/file/index.d.ts +7 -0
  78. package/dist/esm/command/api/dataset/file/index.js +73 -0
  79. package/dist/esm/command/api/dataset/index.js +4 -0
  80. package/dist/esm/command/api/dataset/record/index.d.ts +7 -0
  81. package/dist/esm/command/api/dataset/record/index.js +80 -0
  82. package/dist/esm/command/api/file/index.d.ts +7 -0
  83. package/dist/esm/command/api/file/index.js +68 -0
  84. package/dist/esm/command/api/index.js +17 -1
  85. package/dist/esm/command/api/integration/discord/index.d.ts +7 -0
  86. package/dist/esm/command/api/integration/discord/index.js +68 -0
  87. package/dist/esm/command/api/integration/email/index.d.ts +7 -0
  88. package/dist/esm/command/api/integration/email/index.js +68 -0
  89. package/dist/esm/command/api/integration/extract/index.d.ts +6 -0
  90. package/dist/esm/command/api/integration/extract/index.js +58 -0
  91. package/dist/esm/command/api/integration/index.d.ts +3 -0
  92. package/dist/esm/command/api/integration/index.js +40 -0
  93. package/dist/esm/command/api/integration/instagram/index.d.ts +7 -0
  94. package/dist/esm/command/api/integration/instagram/index.js +68 -0
  95. package/dist/esm/command/api/integration/mcpserver/index.d.ts +6 -0
  96. package/dist/esm/command/api/integration/mcpserver/index.js +58 -0
  97. package/dist/esm/command/api/integration/messenger/index.d.ts +7 -0
  98. package/dist/esm/command/api/integration/messenger/index.js +68 -0
  99. package/dist/esm/command/api/integration/notion/index.d.ts +7 -0
  100. package/dist/esm/command/api/integration/notion/index.js +68 -0
  101. package/dist/esm/command/api/integration/sitemap/index.d.ts +7 -0
  102. package/dist/esm/command/api/integration/sitemap/index.js +68 -0
  103. package/dist/esm/command/api/integration/slack/index.d.ts +7 -0
  104. package/dist/esm/command/api/integration/slack/index.js +68 -0
  105. package/dist/esm/command/api/integration/support/index.d.ts +6 -0
  106. package/dist/esm/command/api/integration/support/index.js +58 -0
  107. package/dist/esm/command/api/integration/telegram/index.d.ts +7 -0
  108. package/dist/esm/command/api/integration/telegram/index.js +68 -0
  109. package/dist/esm/command/api/integration/trigger/index.d.ts +7 -0
  110. package/dist/esm/command/api/integration/trigger/index.js +68 -0
  111. package/dist/esm/command/api/integration/twilio/index.d.ts +7 -0
  112. package/dist/esm/command/api/integration/twilio/index.js +68 -0
  113. package/dist/esm/command/api/integration/whatsapp/index.d.ts +7 -0
  114. package/dist/esm/command/api/integration/whatsapp/index.js +68 -0
  115. package/dist/esm/command/api/integration/widget/index.d.ts +7 -0
  116. package/dist/esm/command/api/integration/widget/index.js +68 -0
  117. package/dist/esm/command/api/memory/index.d.ts +7 -0
  118. package/dist/esm/command/api/memory/index.js +76 -0
  119. package/dist/esm/command/api/secret/index.d.ts +8 -0
  120. package/dist/esm/command/api/secret/index.js +78 -0
  121. package/dist/esm/command/api/skillset/ability/index.d.ts +7 -0
  122. package/dist/esm/command/api/skillset/ability/index.js +80 -0
  123. package/dist/esm/command/api/skillset/index.js +2 -0
  124. package/dist/esm/command/api/team/index.d.ts +4 -0
  125. package/dist/esm/command/api/team/index.js +39 -0
  126. package/dist/esm/command/run/index.d.ts +3 -0
  127. package/dist/esm/command/run/index.js +80 -0
  128. package/dist/esm/index.d.ts +4 -0
  129. package/dist/esm/index.js +4 -1
  130. package/dist/esm/input.d.ts +5 -0
  131. package/dist/esm/input.js +27 -0
  132. package/dist/esm/loader/hooks.d.ts +4 -0
  133. package/dist/esm/loader/hooks.js +79 -0
  134. package/dist/esm/loader/index.d.ts +1 -0
  135. package/dist/esm/loader/index.js +6 -0
  136. package/dist/esm/solution/index.d.ts +104 -64
  137. package/dist/esm/solution/index.js +7 -1
  138. package/package.json +884 -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;
@@ -0,0 +1,7 @@
1
+ export const abilityList: Command;
2
+ export const abilityFetch: Command;
3
+ export const abilityDelete: Command;
4
+ export const abilityExport: Command;
5
+ export const command: Command;
6
+ export default command;
7
+ import { Command } from 'commander';
@@ -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("@chatbotkit/sdk/skillset/index.js");
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 index_js_1.SkillsetClient({
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;
@@ -0,0 +1,4 @@
1
+ export const teamList: Command;
2
+ export const command: Command;
3
+ export default command;
4
+ import { Command } from 'commander';
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.command = void 0;
4
+ const output_js_1 = require("../../output.cjs");
5
+ const child_process_1 = require("child_process");
6
+ const commander_1 = require("commander");
7
+ const fs_1 = require("fs");
8
+ const path_1 = require("path");
9
+ const url_1 = require("url");
10
+ const __dirname = (0, path_1.dirname)((0, url_1.fileURLToPath)(import.meta.url));
11
+ const loaderPath = (0, path_1.join)(__dirname, '..', '..', 'loader', 'index.js');
12
+ function resolveScriptPath(scriptPath) {
13
+ if ((0, path_1.isAbsolute)(scriptPath)) {
14
+ return scriptPath;
15
+ }
16
+ return (0, path_1.resolve)(process.cwd(), scriptPath);
17
+ }
18
+ async function runScript(scriptPath, scriptArgs) {
19
+ const absolutePath = resolveScriptPath(scriptPath);
20
+ if (!(0, fs_1.existsSync)(absolutePath)) {
21
+ (0, output_js_1.printError)(new output_js_1.CommandError(`Script not found: ${scriptPath}`));
22
+ }
23
+ return new Promise((resolve) => {
24
+ const child = (0, child_process_1.spawn)(process.execPath, [
25
+ '--import',
26
+ loaderPath,
27
+ absolutePath,
28
+ ...scriptArgs,
29
+ ], {
30
+ stdio: 'inherit',
31
+ env: {
32
+ ...process.env,
33
+ CBK_API_KEY: process.env.CBK_API_KEY || process.env.CHATBOTKIT_API_KEY,
34
+ },
35
+ cwd: process.cwd(),
36
+ });
37
+ child.on('close', (code) => {
38
+ resolve(code ?? 0);
39
+ });
40
+ child.on('error', (err) => {
41
+ (0, output_js_1.printError)(new output_js_1.CommandError(`Failed to run script: ${err.message}`));
42
+ });
43
+ });
44
+ }
45
+ exports.command = new commander_1.Command()
46
+ .name('run')
47
+ .description('Run a JavaScript file with @chatbotkit/* packages available')
48
+ .argument('<script>', 'Path to the JavaScript file to run')
49
+ .argument('[args...]', 'Arguments to pass to the script')
50
+ .allowUnknownOption(true)
51
+ .allowExcessArguments(true)
52
+ .helpOption('-h, --help', 'Display help for the run command')
53
+ .addHelpText('after', `
54
+ Examples:
55
+ $ cbk run script.js
56
+ $ cbk run ./scripts/deploy.js --env production
57
+ $ cbk run analyze.js data.json
58
+
59
+ Available packages (no installation required):
60
+ @chatbotkit/sdk - Main SDK for ChatBotKit API
61
+ @chatbotkit/agent - Agent utilities for building AI agents
62
+ @chatbotkit/fetch - Fetch utilities
63
+ @chatbotkit/cli - CLI utilities (Command, Option, Argument)
64
+
65
+ Example script:
66
+ import { ChatBotKit } from '@chatbotkit/sdk'
67
+ import { Command } from '@chatbotkit/cli'
68
+
69
+ const program = new Command()
70
+ .option('-e, --env <env>', 'Environment', 'production')
71
+ .parse()
72
+
73
+ const client = new ChatBotKit({
74
+ secret: process.env.CBK_API_KEY
75
+ })
76
+
77
+ console.log('Running in', program.opts().env)
78
+ `)
79
+ .action(async (script, args) => {
80
+ const exitCode = await runScript(script, args);
81
+ process.exit(exitCode);
82
+ });
83
+ exports.default = exports.command;
@@ -0,0 +1,3 @@
1
+ export const command: Command;
2
+ export default command;
3
+ import { Command } from 'commander';
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Argument = exports.Option = exports.Command = void 0;
3
4
  exports.default = cbk;
4
5
  const tslib_1 = require("tslib");
5
6
  const color_js_1 = require("./color.cjs");
6
7
  const index_js_1 = tslib_1.__importDefault(require("./command/agent/index.cjs"));
7
8
  const index_js_2 = tslib_1.__importDefault(require("./command/api/index.cjs"));
8
9
  const index_js_3 = tslib_1.__importDefault(require("./command/chat/index.cjs"));
9
- const index_js_4 = tslib_1.__importDefault(require("./command/solution/index.cjs"));
10
+ const index_js_4 = tslib_1.__importDefault(require("./command/run/index.cjs"));
11
+ const index_js_5 = tslib_1.__importDefault(require("./command/solution/index.cjs"));
10
12
  const commander_1 = require("commander");
13
+ Object.defineProperty(exports, "Argument", { enumerable: true, get: function () { return commander_1.Argument; } });
14
+ Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return commander_1.Command; } });
15
+ Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return commander_1.Option; } });
11
16
  function printBanner() {
12
17
  console.log((0, color_js_1.formatBlue)(`
13
18
  .d8888b. 888888b. 888 d8P
@@ -32,5 +37,6 @@ async function cbk(argv = process.argv) {
32
37
  program.addCommand(index_js_1.default);
33
38
  program.addCommand(index_js_3.default);
34
39
  program.addCommand(index_js_4.default);
40
+ program.addCommand(index_js_5.default);
35
41
  program.parse(argv);
36
42
  }
@@ -1 +1,5 @@
1
1
  export default function cbk(argv?: string[]): Promise<void>;
2
+ import { Command } from 'commander';
3
+ import { Option } from 'commander';
4
+ import { Argument } from 'commander';
5
+ export { Command, Option, Argument };
@@ -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
+ }
@@ -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
+ };
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolve = resolve;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const url_1 = require("url");
7
+ const __dirname = (0, path_1.dirname)((0, url_1.fileURLToPath)(import.meta.url));
8
+ const cliRoot = (0, path_1.join)(__dirname, '..', '..');
9
+ const cliNodeModules = (0, path_1.join)(cliRoot, 'node_modules');
10
+ function resolvePackageExport(packagePath, subpath) {
11
+ const packageJsonPath = (0, path_1.join)(packagePath, 'package.json');
12
+ if (!(0, fs_1.existsSync)(packageJsonPath)) {
13
+ return null;
14
+ }
15
+ try {
16
+ const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, 'utf-8'));
17
+ const exportKey = subpath ? './' + subpath : '.';
18
+ if (packageJson.exports) {
19
+ const exportEntry = packageJson.exports[exportKey];
20
+ if (exportEntry) {
21
+ let importPath;
22
+ if (typeof exportEntry === 'string') {
23
+ importPath = exportEntry;
24
+ }
25
+ else if (exportEntry.import) {
26
+ importPath = exportEntry.import;
27
+ }
28
+ else if (exportEntry.default) {
29
+ importPath = exportEntry.default;
30
+ }
31
+ if (importPath) {
32
+ const resolved = (0, path_1.join)(packagePath, importPath);
33
+ if ((0, fs_1.existsSync)(resolved)) {
34
+ return resolved;
35
+ }
36
+ }
37
+ }
38
+ }
39
+ if (!subpath && packageJson.main) {
40
+ const resolved = (0, path_1.join)(packagePath, packageJson.main);
41
+ if ((0, fs_1.existsSync)(resolved)) {
42
+ return resolved;
43
+ }
44
+ }
45
+ if (!subpath) {
46
+ const indexPath = (0, path_1.join)(packagePath, 'index.js');
47
+ if ((0, fs_1.existsSync)(indexPath)) {
48
+ return indexPath;
49
+ }
50
+ }
51
+ }
52
+ catch {
53
+ }
54
+ return null;
55
+ }
56
+ async function resolve(specifier, context, nextResolve) {
57
+ if (specifier.startsWith('@chatbotkit/')) {
58
+ const parts = specifier.split('/');
59
+ const packageName = parts[0] + '/' + parts[1];
60
+ const subpath = parts.slice(2).join('/');
61
+ if (packageName === '@chatbotkit/cli') {
62
+ const resolved = resolvePackageExport(cliRoot, subpath);
63
+ if (resolved) {
64
+ return {
65
+ url: (0, url_1.pathToFileURL)(resolved).href,
66
+ shortCircuit: true,
67
+ };
68
+ }
69
+ }
70
+ const packagePath = (0, path_1.join)(cliNodeModules, packageName);
71
+ if ((0, fs_1.existsSync)(packagePath)) {
72
+ const resolved = resolvePackageExport(packagePath, subpath);
73
+ if (resolved) {
74
+ return {
75
+ url: (0, url_1.pathToFileURL)(resolved).href,
76
+ shortCircuit: true,
77
+ };
78
+ }
79
+ }
80
+ }
81
+ return nextResolve(specifier, context);
82
+ }
@@ -0,0 +1,4 @@
1
+ export function resolve(specifier: string, context: object, nextResolve: Function): Promise<{
2
+ url: string;
3
+ shortCircuit?: boolean;
4
+ }>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_module_1 = require("node:module");
4
+ const path_1 = require("path");
5
+ const url_1 = require("url");
6
+ const __dirname = (0, path_1.dirname)((0, url_1.fileURLToPath)(import.meta.url));
7
+ const hooksPath = (0, path_1.join)(__dirname, 'hooks.js');
8
+ (0, node_module_1.register)((0, url_1.pathToFileURL)(hooksPath).href, import.meta.url);
@@ -0,0 +1 @@
1
+ export {};
@@ -60,6 +60,7 @@ exports.BasicResourceConfigSchema = zod_1.z.object({
60
60
  exports.BlueprintResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
61
61
  type: zod_1.z.literal('blueprint'),
62
62
  properties: zod_1.z.object({
63
+ alias: zod_1.z.string().optional(),
63
64
  name: zod_1.z.string().optional(),
64
65
  description: zod_1.z.string().optional(),
65
66
  meta: zod_1.z.record(zod_1.z.unknown()).optional(),
@@ -69,6 +70,7 @@ exports.BlueprintResourceConfigSchema = exports.BasicResourceConfigSchema.extend
69
70
  exports.BotResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
70
71
  type: zod_1.z.literal('bot'),
71
72
  properties: zod_1.z.object({
73
+ alias: zod_1.z.string().optional(),
72
74
  name: zod_1.z.string().optional(),
73
75
  description: zod_1.z.string().optional(),
74
76
  meta: zod_1.z.record(zod_1.z.unknown()).optional(),
@@ -85,6 +87,7 @@ exports.BotResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
85
87
  exports.DatasetResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
86
88
  type: zod_1.z.literal('dataset'),
87
89
  properties: zod_1.z.object({
90
+ alias: zod_1.z.string().optional(),
88
91
  name: zod_1.z.string().optional(),
89
92
  description: zod_1.z.string().optional(),
90
93
  meta: zod_1.z.record(zod_1.z.unknown()).optional(),
@@ -104,6 +107,7 @@ exports.DatasetResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
104
107
  exports.FileResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
105
108
  type: zod_1.z.literal('file'),
106
109
  properties: zod_1.z.object({
110
+ alias: zod_1.z.string().optional(),
107
111
  name: zod_1.z.string().optional(),
108
112
  description: zod_1.z.string().optional(),
109
113
  meta: zod_1.z.record(zod_1.z.unknown()).optional(),
@@ -114,6 +118,7 @@ exports.FileResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
114
118
  exports.SecretResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
115
119
  type: zod_1.z.literal('secret'),
116
120
  properties: zod_1.z.object({
121
+ alias: zod_1.z.string().optional(),
117
122
  name: zod_1.z.string().optional(),
118
123
  description: zod_1.z.string().optional(),
119
124
  meta: zod_1.z.record(zod_1.z.unknown()).optional(),
@@ -130,6 +135,7 @@ exports.SecretResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
130
135
  exports.SkillsetResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
131
136
  type: zod_1.z.literal('skillset'),
132
137
  properties: zod_1.z.object({
138
+ alias: zod_1.z.string().optional(),
133
139
  name: zod_1.z.string().optional(),
134
140
  description: zod_1.z.string().optional(),
135
141
  meta: zod_1.z.record(zod_1.z.unknown()).optional(),
@@ -344,7 +350,7 @@ exports.ExtractIntegrationResourceConfigSchema = exports.BasicResourceConfigSche
344
350
  botId: zod_1.z.string().optional(),
345
351
  schema: zod_1.z.record(zod_1.z.unknown()).optional(),
346
352
  request: zod_1.z.string().optional(),
347
- trigger: zod_1.z.string().optional(),
353
+ model: zod_1.z.string().optional(),
348
354
  }),
349
355
  });
350
356
  exports.McpServerIntegrationResourceConfigSchema = exports.BasicResourceConfigSchema.extend({
@@ -1,3 +1,7 @@
1
1
  export const BLUE: "\u001B[34m";
2
+ export const RED: "\u001B[31m";
3
+ export const YELLOW: "\u001B[33m";
2
4
  export const RESET: "\u001B[0m";
3
5
  export function formatBlue(text: string): string;
6
+ export function formatRed(text: string): string;
7
+ export function formatYellow(text: string): string;
package/dist/esm/color.js CHANGED
@@ -1,5 +1,13 @@
1
1
  export const BLUE = '\u001b[34m';
2
+ export const RED = '\u001b[31m';
3
+ export const YELLOW = '\u001b[33m';
2
4
  export const RESET = '\u001b[0m';
3
5
  export const formatBlue = (text) => {
4
6
  return `${BLUE}${text}${RESET}`;
5
7
  };
8
+ export const formatRed = (text) => {
9
+ return `${RED}${text}${RESET}`;
10
+ };
11
+ export const formatYellow = (text) => {
12
+ return `${YELLOW}${text}${RESET}`;
13
+ };
@@ -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,6 @@
1
+ export const botList: Command;
2
+ export const botFetch: Command;
3
+ export const botDelete: Command;
4
+ export const command: Command;
5
+ export default command;
6
+ import { Command } from 'commander';
@@ -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;