@codebolt/codeboltjs 2.0.0 → 2.0.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.
@@ -63,7 +63,7 @@ class UserMessage {
63
63
  else {
64
64
  let finalPrompt = `
65
65
  The user has sent the following query:
66
- ${this.message.userMessage}.
66
+ <user_query> ${this.message.userMessage} </user_query>.
67
67
  `;
68
68
  if ((_a = this.message.mentionedFiles) === null || _a === void 0 ? void 0 : _a.length) {
69
69
  finalPrompt += `The Attached files are:`;
@@ -105,8 +105,11 @@ class UserMessage {
105
105
  * @returns Promise with an array of MCP tools
106
106
  */
107
107
  async getMentionedMcpsTools() {
108
+ console.log("mentionedMCPs", this.mentionedMCPs);
108
109
  if (this.mentionedMCPs.length > 0) {
110
+ console.log("mentionedMCPs", this.mentionedMCPs);
109
111
  let tools = await tools_1.default.listToolsFromToolBoxes(this.mentionedMCPs);
112
+ console.log("tools", tools);
110
113
  return tools;
111
114
  }
112
115
  else {
@@ -1,36 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  const websocket_1 = __importDefault(require("./websocket"));
30
- const fs = __importStar(require("fs"));
31
- const path_1 = __importDefault(require("path"));
32
- const tree_sitter_1 = __importDefault(require("tree-sitter"));
33
- const tree_sitter_javascript_1 = __importDefault(require("tree-sitter-javascript"));
34
7
  /**
35
8
  * A utility module for working with code.
36
9
  */
@@ -50,46 +23,43 @@ const cbcodeutils = {
50
23
  const response = JSON.parse(data);
51
24
  if (response.type === "getProjectPathResponse") {
52
25
  // resolve(response);
53
- try {
54
- let pathInput = filePath || response.projectPath;
55
- let parser = new tree_sitter_1.default();
56
- // Initialize the parser with the JavaScript language
57
- parser.setLanguage(tree_sitter_javascript_1.default);
58
- const trees = [];
59
- const functionNodes = [];
60
- const processDirectory = (directory) => {
61
- // Read all files in the directory
62
- const files = fs.readdirSync(directory, { withFileTypes: true });
63
- files.forEach(file => {
64
- if (file.isDirectory()) {
65
- if (file.name !== 'node_modules') { // Ignore node_modules directory
66
- processDirectory(path_1.default.join(directory, file.name)); // Recursive call for subdirectories
67
- }
68
- }
69
- else if (path_1.default.extname(file.name) === '.js') {
70
- const code = fs.readFileSync(path_1.default.join(directory, file.name), 'utf-8');
71
- let tree = parser.parse(code);
72
- tree.rootNode.path = path_1.default.join(directory, file.name); // Set file path for t
73
- trees.push(tree);
74
- }
75
- });
76
- };
77
- if (fs.lstatSync(pathInput).isDirectory()) {
78
- processDirectory(pathInput);
79
- }
80
- else if (path_1.default.extname(pathInput) === '.js') {
81
- // Read a single JavaScript file
82
- const code = fs.readFileSync(pathInput, 'utf-8');
83
- let tree = parser.parse(code);
84
- tree.rootNode.path = pathInput; // Set file path for t
85
- trees.push(tree);
86
- }
87
- resolve({ event: 'GetJsTreeResponse', payload: trees }); // Return an array of abstract syntax trees (ASTs)
88
- }
89
- catch (error) {
90
- console.error('An error occurred:', error);
91
- return { event: 'GetJsTreeResponse', payload: null }; // Return null in case of error
92
- }
26
+ // try {
27
+ // let pathInput = filePath || response.projectPath;
28
+ // let parser = new Parser();
29
+ // // Initialize the parser with the JavaScript language
30
+ // parser.setLanguage(JavaScript);
31
+ // const trees = [];
32
+ // const functionNodes = [];
33
+ // const processDirectory = (directory: any) => {
34
+ // // Read all files in the directory
35
+ // const files = fs.readdirSync(directory, { withFileTypes: true });
36
+ // files.forEach(file => {
37
+ // if (file.isDirectory()) {
38
+ // if (file.name !== 'node_modules') { // Ignore node_modules directory
39
+ // processDirectory(path.join(directory, file.name)); // Recursive call for subdirectories
40
+ // }
41
+ // } else if (path.extname(file.name) === '.js') {
42
+ // const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
43
+ // let tree: any = parser.parse(code);
44
+ // tree.rootNode.path = path.join(directory, file.name); // Set file path for t
45
+ // trees.push(tree);
46
+ // }
47
+ // });
48
+ // };
49
+ // if (fs.lstatSync(pathInput).isDirectory()) {
50
+ // processDirectory(pathInput);
51
+ // } else if (path.extname(pathInput) === '.js') {
52
+ // // Read a single JavaScript file
53
+ // const code = fs.readFileSync(pathInput, 'utf-8');
54
+ // let tree: any = parser.parse(code);
55
+ // tree.rootNode.path = pathInput; // Set file path for t
56
+ // trees.push(tree);
57
+ // }
58
+ // resolve({ event: 'GetJsTreeResponse', payload: trees }); // Return an array of abstract syntax trees (ASTs)
59
+ // } catch (error) {
60
+ // console.error('An error occurred:', error);
61
+ // return { event: 'GetJsTreeResponse', payload: null }; // Return null in case of error
62
+ // }
93
63
  }
94
64
  });
95
65
  });
@@ -53,7 +53,8 @@ class cbws {
53
53
  const agentIdParam = process.env.agentId ? `&agentId=${process.env.agentId}` : '';
54
54
  const parentIdParam = process.env.parentId ? `&parentId=${process.env.parentId}` : '';
55
55
  const parentAgentInstanceIdParam = process.env.parentAgentInstanceId ? `&parentAgentInstanceId=${process.env.parentAgentInstanceId}` : '';
56
- this.websocket = new ws_1.default(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${process.env.Is_Dev ? '&dev=true' : ''}`);
56
+ const agentTask = process.env.agentTask ? `&agentTask=${process.env.agentTask}` : '';
57
+ this.websocket = new ws_1.default(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${process.env.Is_Dev ? '&dev=true' : ''}`);
57
58
  return new Promise((resolve, reject) => {
58
59
  this.websocket.on('error', (error) => {
59
60
  reject(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -29,10 +29,6 @@
29
29
  "mcp-proxy": "^2.4.0",
30
30
  "strict-event-emitter-types": "^2.0.0",
31
31
  "timers": "^0.1.1",
32
- "tree-sitter": "^0.21.1",
33
- "tree-sitter-javascript": "^0.23.1",
34
- "tree-sitter-typescript": "^0.23.2",
35
- "typedoc-plugin-missing-exports": "^2.2.0",
36
32
  "undici": "^7.4.0",
37
33
  "uri-templates": "^0.2.0",
38
34
  "ws": "^8.17.0",
@@ -76,6 +76,7 @@ class UserMessage {
76
76
  */
77
77
  constructor(message: Message, promptOverride: boolean = false) {
78
78
  this.message = message;
79
+
79
80
  this.promptOverride = promptOverride;
80
81
  this.userMessages = [];
81
82
  this.mentionedMCPs = message.mentionedMCPs || [];
@@ -108,7 +109,7 @@ class UserMessage {
108
109
  } else {
109
110
  let finalPrompt = `
110
111
  The user has sent the following query:
111
- ${this.message.userMessage}.
112
+ <user_query> ${this.message.userMessage} </user_query>.
112
113
  `;
113
114
  if (this.message.mentionedFiles?.length) {
114
115
  finalPrompt += `The Attached files are:`;
@@ -155,8 +156,11 @@ class UserMessage {
155
156
  * @returns Promise with an array of MCP tools
156
157
  */
157
158
  async getMentionedMcpsTools() {
159
+ console.log("mentionedMCPs", this.mentionedMCPs);
158
160
  if (this.mentionedMCPs.length > 0) {
161
+ console.log("mentionedMCPs", this.mentionedMCPs);
159
162
  let tools = await mcp.listToolsFromToolBoxes(this.mentionedMCPs)
163
+ console.log("tools", tools);
160
164
  return tools
161
165
  }
162
166
  else {
@@ -1,9 +1,9 @@
1
1
  import cbws from './websocket';
2
2
  import * as fs from 'fs';
3
3
  import path from 'path';
4
- import Parser from 'tree-sitter';
5
- import JavaScript from 'tree-sitter-javascript';
6
- import typescript from "tree-sitter-typescript"; // TypeScript and TSX grammar
4
+ // import Parser from 'tree-sitter';
5
+ // import JavaScript from 'tree-sitter-javascript';
6
+ // import typescript from "tree-sitter-typescript"; // TypeScript and TSX grammar
7
7
 
8
8
  import { GetJsTreeResponse, MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '@codebolt/types';
9
9
 
@@ -27,47 +27,47 @@ const cbcodeutils = {
27
27
  const response = JSON.parse(data);
28
28
  if (response.type === "getProjectPathResponse") {
29
29
  // resolve(response);
30
- try {
31
- let pathInput = filePath || response.projectPath;
32
- let parser = new Parser();
33
- // Initialize the parser with the JavaScript language
34
- parser.setLanguage(JavaScript);
35
- const trees = [];
36
- const functionNodes = [];
37
- const processDirectory = (directory: any) => {
38
- // Read all files in the directory
39
- const files = fs.readdirSync(directory, { withFileTypes: true });
30
+ // try {
31
+ // let pathInput = filePath || response.projectPath;
32
+ // let parser = new Parser();
33
+ // // Initialize the parser with the JavaScript language
34
+ // parser.setLanguage(JavaScript);
35
+ // const trees = [];
36
+ // const functionNodes = [];
37
+ // const processDirectory = (directory: any) => {
38
+ // // Read all files in the directory
39
+ // const files = fs.readdirSync(directory, { withFileTypes: true });
40
40
 
41
- files.forEach(file => {
42
- if (file.isDirectory()) {
43
- if (file.name !== 'node_modules') { // Ignore node_modules directory
44
- processDirectory(path.join(directory, file.name)); // Recursive call for subdirectories
45
- }
46
- } else if (path.extname(file.name) === '.js') {
47
- const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
48
- let tree: any = parser.parse(code);
49
- tree.rootNode.path = path.join(directory, file.name); // Set file path for t
50
- trees.push(tree);
51
- }
52
- });
53
- };
41
+ // files.forEach(file => {
42
+ // if (file.isDirectory()) {
43
+ // if (file.name !== 'node_modules') { // Ignore node_modules directory
44
+ // processDirectory(path.join(directory, file.name)); // Recursive call for subdirectories
45
+ // }
46
+ // } else if (path.extname(file.name) === '.js') {
47
+ // const code = fs.readFileSync(path.join(directory, file.name), 'utf-8');
48
+ // let tree: any = parser.parse(code);
49
+ // tree.rootNode.path = path.join(directory, file.name); // Set file path for t
50
+ // trees.push(tree);
51
+ // }
52
+ // });
53
+ // };
54
54
 
55
- if (fs.lstatSync(pathInput).isDirectory()) {
56
- processDirectory(pathInput);
57
- } else if (path.extname(pathInput) === '.js') {
58
- // Read a single JavaScript file
59
- const code = fs.readFileSync(pathInput, 'utf-8');
60
- let tree: any = parser.parse(code);
61
- tree.rootNode.path = pathInput; // Set file path for t
55
+ // if (fs.lstatSync(pathInput).isDirectory()) {
56
+ // processDirectory(pathInput);
57
+ // } else if (path.extname(pathInput) === '.js') {
58
+ // // Read a single JavaScript file
59
+ // const code = fs.readFileSync(pathInput, 'utf-8');
60
+ // let tree: any = parser.parse(code);
61
+ // tree.rootNode.path = pathInput; // Set file path for t
62
62
 
63
- trees.push(tree);
64
- }
63
+ // trees.push(tree);
64
+ // }
65
65
 
66
- resolve({ event: 'GetJsTreeResponse', payload: trees }); // Return an array of abstract syntax trees (ASTs)
67
- } catch (error) {
68
- console.error('An error occurred:', error);
69
- return { event: 'GetJsTreeResponse', payload: null }; // Return null in case of error
70
- }
66
+ // resolve({ event: 'GetJsTreeResponse', payload: trees }); // Return an array of abstract syntax trees (ASTs)
67
+ // } catch (error) {
68
+ // console.error('An error occurred:', error);
69
+ // return { event: 'GetJsTreeResponse', payload: null }; // Return null in case of error
70
+ // }
71
71
  }
72
72
  });
73
73
 
@@ -728,7 +728,7 @@ export class FastMCPSession<T extends FastMCPSessionAuth = FastMCPSessionAuth> e
728
728
  public async requestSampling(
729
729
  message: z.infer<typeof CreateMessageRequestSchema>["params"],
730
730
  ): Promise<SamplingResponse> {
731
- return this.#server.createMessage(message);
731
+ return this.#server.createMessage(message) as unknown as SamplingResponse;
732
732
  }
733
733
 
734
734
  public async connect(transport: Transport) {
@@ -56,7 +56,8 @@ class cbws {
56
56
  const agentIdParam = process.env.agentId ? `&agentId=${process.env.agentId}` : '';
57
57
  const parentIdParam = process.env.parentId ? `&parentId=${process.env.parentId}` : '';
58
58
  const parentAgentInstanceIdParam = process.env.parentAgentInstanceId ? `&parentAgentInstanceId=${process.env.parentAgentInstanceId}` : '';
59
- this.websocket = new WebSocket(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${process.env.Is_Dev ? '&dev=true' : ''}`);
59
+ const agentTask = process.env.agentTask ? `&agentTask=${process.env.agentTask}` : '';
60
+ this.websocket = new WebSocket(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${process.env.Is_Dev ? '&dev=true' : ''}`);
60
61
 
61
62
  return new Promise((resolve, reject) => {
62
63
  this.websocket.on('error', (error: Error) => {