@chatbotkit/cli 1.26.1 → 1.26.2

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.
@@ -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 child_process_1 = require("child_process");
7
- const promises_1 = require("fs/promises");
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(exports.tools).filter(([, tool]) => tool.default));
10
+ return Object.fromEntries(Object.entries(agent_1.tools).filter(([, tool]) => tool.default));
192
11
  }
193
- return Object.fromEntries(Object.entries(exports.tools).filter(([name]) => selectedTools.includes(name)));
12
+ return Object.fromEntries(Object.entries(agent_1.tools).filter(([name]) => selectedTools.includes(name)));
194
13
  }
195
14
  function getToolNames() {
196
- return Object.keys(exports.tools);
15
+ return Object.keys(agent_1.tools);
197
16
  }
@@ -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 const tools: Record<string, {
4
- description: string;
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';
@@ -632,10 +632,10 @@ export const SolutionConfigSchema: z.ZodObject<{
632
632
  } | {
633
633
  type: "widgetIntegration";
634
634
  properties: {
635
- stream?: boolean | undefined;
636
635
  attachments?: boolean | undefined;
637
636
  botId?: string | undefined;
638
637
  tools?: boolean | undefined;
638
+ stream?: boolean | undefined;
639
639
  name?: string | undefined;
640
640
  description?: string | undefined;
641
641
  meta?: {
@@ -992,10 +992,10 @@ export const SolutionConfigSchema: z.ZodObject<{
992
992
  } | {
993
993
  type: "widgetIntegration";
994
994
  properties: {
995
- stream?: boolean | undefined;
996
995
  attachments?: boolean | undefined;
997
996
  botId?: string | undefined;
998
997
  tools?: boolean | undefined;
998
+ stream?: boolean | undefined;
999
999
  name?: string | undefined;
1000
1000
  description?: string | undefined;
1001
1001
  meta?: {
@@ -1353,10 +1353,10 @@ export class Resource {
1353
1353
  } | {
1354
1354
  type: "widgetIntegration";
1355
1355
  properties: {
1356
- stream?: boolean | undefined;
1357
1356
  attachments?: boolean | undefined;
1358
1357
  botId?: string | undefined;
1359
1358
  tools?: boolean | undefined;
1359
+ stream?: boolean | undefined;
1360
1360
  name?: string | undefined;
1361
1361
  description?: string | undefined;
1362
1362
  meta?: {
@@ -1794,10 +1794,10 @@ export class Solution {
1794
1794
  } | {
1795
1795
  type: "widgetIntegration";
1796
1796
  properties: {
1797
- stream?: boolean | undefined;
1798
1797
  attachments?: boolean | undefined;
1799
1798
  botId?: string | undefined;
1800
1799
  tools?: boolean | undefined;
1800
+ stream?: boolean | undefined;
1801
1801
  name?: string | undefined;
1802
1802
  description?: string | undefined;
1803
1803
  meta?: {
@@ -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 const tools: Record<string, {
4
- description: string;
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';
package/dist/esm/tools.js CHANGED
@@ -1,186 +1,5 @@
1
- import { exec, spawn } from 'child_process';
2
- import { readFile, writeFile } from 'fs/promises';
3
- import { promisify } from 'util';
4
- import { z } from 'zod';
5
- const execAsync = promisify(exec);
6
- export const tools = {
7
- read: {
8
- description: 'Read the contents of a file',
9
- default: true,
10
- input: z.object({
11
- path: z.string().describe('The file path to read'),
12
- }),
13
- handler: async (input) => {
14
- try {
15
- const content = await readFile(input.path, 'utf-8');
16
- return { success: true, content };
17
- }
18
- catch (error) {
19
- return {
20
- success: false,
21
- error: error instanceof Error ? error.message : 'Unknown error',
22
- };
23
- }
24
- },
25
- },
26
- write: {
27
- description: 'Write content to a file',
28
- default: true,
29
- input: z.object({
30
- path: z.string().describe('The file path to write to'),
31
- content: z.string().describe('The content to write'),
32
- }),
33
- handler: async (input) => {
34
- try {
35
- await writeFile(input.path, input.content, 'utf-8');
36
- return { success: true };
37
- }
38
- catch (error) {
39
- return {
40
- success: false,
41
- error: error instanceof Error ? error.message : 'Unknown error',
42
- };
43
- }
44
- },
45
- },
46
- edit: {
47
- description: 'Edit a file by replacing an exact string occurrence with a new string. Only one occurrence must exist.',
48
- default: true,
49
- input: z.object({
50
- path: z.string().describe('The file path to edit'),
51
- oldString: z
52
- .string()
53
- .describe('The exact string to find and replace (must match exactly)'),
54
- newString: z.string().describe('The new string to replace with'),
55
- }),
56
- handler: async (input) => {
57
- try {
58
- const content = await readFile(input.path, 'utf-8');
59
- const occurrences = content.split(input.oldString).length - 1;
60
- if (occurrences === 0) {
61
- return {
62
- success: false,
63
- error: 'String not found in file',
64
- };
65
- }
66
- if (occurrences > 1) {
67
- return {
68
- success: false,
69
- error: `Multiple occurrences found (${occurrences}). The old string must match exactly one location.`,
70
- };
71
- }
72
- const newContent = content.replace(input.oldString, input.newString);
73
- await writeFile(input.path, newContent, 'utf-8');
74
- const oldPreview = input.oldString.length > 100
75
- ? input.oldString.substring(0, 100) + '...'
76
- : input.oldString;
77
- const newPreview = input.newString.length > 100
78
- ? input.newString.substring(0, 100) + '...'
79
- : input.newString;
80
- return {
81
- success: true,
82
- message: `Successfully replaced:\n OLD: ${oldPreview}\n NEW: ${newPreview}`,
83
- };
84
- }
85
- catch (error) {
86
- return {
87
- success: false,
88
- error: error instanceof Error ? error.message : 'Unknown error',
89
- };
90
- }
91
- },
92
- },
93
- find: {
94
- description: 'Search for files matching a pattern',
95
- default: true,
96
- input: z.object({
97
- pattern: z.string().describe('The glob pattern to search for'),
98
- directory: z
99
- .string()
100
- .optional()
101
- .describe('The directory to search in (defaults to current)'),
102
- }),
103
- handler: async (input) => {
104
- try {
105
- const dir = input.directory || '.';
106
- const { stdout } = await execAsync(`find ${dir} -name "${input.pattern}"`);
107
- const files = stdout.trim().split('\n').filter(Boolean);
108
- return { success: true, files };
109
- }
110
- catch (error) {
111
- return {
112
- success: false,
113
- error: error instanceof Error ? error.message : 'Unknown error',
114
- };
115
- }
116
- },
117
- },
118
- exec: {
119
- 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.',
120
- default: true,
121
- input: z.object({
122
- command: z.string().describe('The command to execute'),
123
- timeout: z
124
- .number()
125
- .default(30)
126
- .describe('Timeout in seconds. The command will be killed if it runs longer than this.'),
127
- }),
128
- handler: async (input) => {
129
- const timeoutMs = input.timeout * 1000;
130
- return new Promise((resolve) => {
131
- const childProcess = spawn('sh', ['-c', input.command], {
132
- stdio: ['ignore', 'pipe', 'pipe'],
133
- timeout: timeoutMs,
134
- });
135
- let stdout = '';
136
- let stderr = '';
137
- let timedOut = false;
138
- childProcess.stdout.on('data', (data) => {
139
- stdout += data.toString();
140
- });
141
- childProcess.stderr.on('data', (data) => {
142
- stderr += data.toString();
143
- });
144
- childProcess.on('close', (code) => {
145
- if (timedOut) {
146
- resolve({
147
- success: false,
148
- error: `Command timed out after ${timeoutMs / 1000} seconds. This may indicate an interactive command.`,
149
- });
150
- }
151
- else if (code === 0) {
152
- resolve({ success: true, stdout, stderr });
153
- }
154
- else {
155
- resolve({
156
- success: false,
157
- error: `Command exited with code ${code}`,
158
- stdout,
159
- stderr,
160
- });
161
- }
162
- });
163
- childProcess.on('error', (error) => {
164
- resolve({
165
- success: false,
166
- error: error.message,
167
- });
168
- });
169
- setTimeout(() => {
170
- if (!childProcess.killed) {
171
- timedOut = true;
172
- childProcess.kill('SIGTERM');
173
- setTimeout(() => {
174
- if (!childProcess.killed) {
175
- childProcess.kill('SIGKILL');
176
- }
177
- }, 2000);
178
- }
179
- }, timeoutMs);
180
- });
181
- },
182
- },
183
- };
1
+ import { tools } from '@chatbotkit/agent';
2
+ export { tools };
184
3
  export function getTools(selectedTools) {
185
4
  if (!selectedTools || selectedTools.length === 0) {
186
5
  return Object.fromEntries(Object.entries(tools).filter(([, tool]) => tool.default));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chatbotkit/cli",
3
- "version": "1.26.1",
3
+ "version": "1.26.2",
4
4
  "description": "ChatBotKit command line tools",
5
5
  "license": "ISC",
6
6
  "engines": {
@@ -537,27 +537,6 @@
537
537
  },
538
538
  "./package.json": "./package.json"
539
539
  },
540
- "types": "./dist/cjs/index.d.ts",
541
- "dependencies": {
542
- "commander": "^11.1.0",
543
- "dotenv": "^16.4.5",
544
- "js-yaml": "^4.1.0",
545
- "tslib": "^2.6.2",
546
- "zod": "^3.25.76",
547
- "@chatbotkit/agent": "1.26.1",
548
- "@chatbotkit/sdk": "1.26.1"
549
- },
550
- "devDependencies": {
551
- "@types/js-yaml": "^4.0.9",
552
- "npm-run-all": "^4.1.5",
553
- "typedoc": "^0.28.14",
554
- "typedoc-plugin-markdown": "^4.9.0",
555
- "typedoc-plugin-mdn-links": "^5.0.10",
556
- "typescript": "^5.9"
557
- },
558
- "files": [
559
- "dist/**"
560
- ],
561
540
  "scripts": {
562
541
  "build": "run-s build:*",
563
542
  "build:01-cjs": "tsc -p tsconfig.cjs.json",
@@ -578,6 +557,29 @@
578
557
  "clean:types": "rimraf types",
579
558
  "dev": "node bin/cbk.js",
580
559
  "lint": "eslint .",
560
+ "postpack": "node ../../scripts/create-standard-exports.js",
561
+ "prepack": "node ../../scripts/create-dist-exports.js",
581
562
  "test": "true"
582
- }
583
- }
563
+ },
564
+ "types": "./dist/cjs/index.d.ts",
565
+ "dependencies": {
566
+ "@chatbotkit/agent": "workspace:*",
567
+ "@chatbotkit/sdk": "workspace:*",
568
+ "commander": "^11.1.0",
569
+ "dotenv": "^16.4.5",
570
+ "js-yaml": "^4.1.0",
571
+ "tslib": "^2.6.2",
572
+ "zod": "^3.25.76"
573
+ },
574
+ "devDependencies": {
575
+ "@types/js-yaml": "^4.0.9",
576
+ "npm-run-all": "^4.1.5",
577
+ "typedoc": "^0.28.14",
578
+ "typedoc-plugin-markdown": "^4.9.0",
579
+ "typedoc-plugin-mdn-links": "^5.0.10",
580
+ "typescript": "^5.9"
581
+ },
582
+ "files": [
583
+ "dist/**"
584
+ ]
585
+ }