@codebolt/codeboltjs 2.0.7 → 2.0.11

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 (52) hide show
  1. package/dist/agentlib/agent.js +12 -4
  2. package/dist/agentlib/promptbuilder.d.ts +228 -0
  3. package/dist/agentlib/promptbuilder.js +487 -0
  4. package/dist/agentlib/taskInstruction.d.ts +3 -25
  5. package/dist/agentlib/usermessage.d.ts +13 -43
  6. package/dist/agentlib/usermessage.js +8 -8
  7. package/dist/core/messageManager.d.ts +4 -6
  8. package/dist/core/messageManager.js +24 -17
  9. package/dist/core/websocket.d.ts +10 -0
  10. package/dist/core/websocket.js +92 -8
  11. package/dist/index.d.ts +97 -95
  12. package/dist/index.js +63 -57
  13. package/dist/modules/agent.d.ts +9 -8
  14. package/dist/modules/agent.js +4 -4
  15. package/dist/modules/browser.d.ts +17 -17
  16. package/dist/modules/browser.js +7 -7
  17. package/dist/modules/chat.d.ts +1 -1
  18. package/dist/modules/codeparsers.d.ts +1 -16
  19. package/dist/modules/codeutils.d.ts +3 -18
  20. package/dist/modules/dbmemory.d.ts +1 -1
  21. package/dist/modules/debug.d.ts +1 -1
  22. package/dist/modules/fs.d.ts +1 -1
  23. package/dist/modules/git.d.ts +21 -20
  24. package/dist/modules/git.js +10 -10
  25. package/dist/modules/history.d.ts +6 -8
  26. package/dist/modules/history.js +4 -1
  27. package/dist/modules/llm.d.ts +13 -5
  28. package/dist/modules/llm.js +29 -4
  29. package/dist/modules/{tools.d.ts → mcp.d.ts} +9 -8
  30. package/dist/modules/{tools.js → mcp.js} +6 -6
  31. package/dist/modules/project.d.ts +1 -1
  32. package/dist/modules/state.d.ts +2 -1
  33. package/dist/modules/task.js +0 -1
  34. package/dist/modules/terminal.d.ts +1 -1
  35. package/dist/modules/tokenizer.d.ts +1 -1
  36. package/dist/modules/utils.d.ts +11 -1
  37. package/dist/modules/utils.js +9 -0
  38. package/dist/modules/vectordb.d.ts +1 -1
  39. package/dist/types/InternalTypes.d.ts +501 -0
  40. package/dist/types/InternalTypes.js +30 -0
  41. package/dist/types/commonTypes.d.ts +346 -0
  42. package/dist/types/commonTypes.js +37 -0
  43. package/dist/types/libFunctionTypes.d.ts +589 -0
  44. package/dist/types/libFunctionTypes.js +11 -0
  45. package/dist/types/socketMessageTypes.d.ts +951 -0
  46. package/dist/types/socketMessageTypes.js +51 -0
  47. package/dist/utils/{toolBox.d.ts → mcpServer.d.ts} +1 -1
  48. package/dist/utils/{toolBox.js → mcpServer.js} +36 -36
  49. package/dist/utils/parse-source-code/languageParser.d.ts +1 -7
  50. package/dist/utils.d.ts +1 -1
  51. package/dist/utils.js +3 -3
  52. package/package.json +6 -1
@@ -60,8 +60,11 @@ class MessageManager extends events_1.EventEmitter {
60
60
  }
61
61
  /**
62
62
  * Send a message and wait for a specific response type
63
+ * @param message The message to send
64
+ * @param expectedResponseType The type of response to wait for
65
+ * @param timeout Optional timeout in milliseconds. If not provided or set to 0, will wait indefinitely
63
66
  */
64
- sendAndWaitForResponse(message, expectedResponseType, timeout = 30000) {
67
+ sendAndWaitForResponse(message, expectedResponseType, timeout = 0) {
65
68
  return new Promise((resolve, reject) => {
66
69
  if (!this.websocket) {
67
70
  reject(new Error('WebSocket is not initialized'));
@@ -72,6 +75,7 @@ class MessageManager extends events_1.EventEmitter {
72
75
  const messageWithId = { ...message, requestId };
73
76
  // Parse multiple message types separated by pipe
74
77
  const messageTypes = expectedResponseType.split('|').map(type => type.trim());
78
+ console.log("Message types: ", messageTypes);
75
79
  // Store the pending request
76
80
  this.pendingRequests.set(requestId, {
77
81
  resolve,
@@ -79,22 +83,25 @@ class MessageManager extends events_1.EventEmitter {
79
83
  messageTypes,
80
84
  requestId
81
85
  });
82
- // Set timeout
83
- const timeoutId = setTimeout(() => {
84
- if (this.pendingRequests.has(requestId)) {
85
- this.pendingRequests.delete(requestId);
86
- reject(new Error(`Request timeout after ${timeout}ms for message types: ${expectedResponseType}`));
87
- }
88
- }, timeout);
89
- // Override resolve to clear timeout
90
- const originalResolve = resolve;
91
- const wrappedResolve = (value) => {
92
- clearTimeout(timeoutId);
93
- originalResolve(value);
94
- };
95
- // Update the stored request with wrapped resolve
96
- const request = this.pendingRequests.get(requestId);
97
- request.resolve = wrappedResolve;
86
+ // Set timeout only if a positive timeout value is provided
87
+ let timeoutId;
88
+ if (timeout > 0) {
89
+ timeoutId = setTimeout(() => {
90
+ if (this.pendingRequests.has(requestId)) {
91
+ this.pendingRequests.delete(requestId);
92
+ reject(new Error(`Request timeout after ${timeout}ms for message types: ${expectedResponseType}`));
93
+ }
94
+ }, timeout);
95
+ // Override resolve to clear timeout
96
+ const originalResolve = resolve;
97
+ const wrappedResolve = (value) => {
98
+ clearTimeout(timeoutId);
99
+ originalResolve(value);
100
+ };
101
+ // Update the stored request with wrapped resolve
102
+ const request = this.pendingRequests.get(requestId);
103
+ request.resolve = wrappedResolve;
104
+ }
98
105
  // Send the message
99
106
  this.websocket.send(JSON.stringify(messageWithId));
100
107
  });
@@ -5,6 +5,7 @@ import { MessageManager } from './messageManager';
5
5
  */
6
6
  declare class cbws {
7
7
  websocket: WebSocket;
8
+ private initialized;
8
9
  /**
9
10
  * Constructs a new cbws instance and initializes the WebSocket connection.
10
11
  */
@@ -23,10 +24,19 @@ declare class cbws {
23
24
  * @throws {Error} If the WebSocket is not open.
24
25
  */
25
26
  get getWebsocket(): WebSocket;
27
+ /**
28
+ * Waits for the WebSocket to be ready and returns it.
29
+ * @returns {Promise<WebSocket>} A promise that resolves with the WebSocket instance when it's ready.
30
+ */
31
+ waitForWebSocket(): Promise<WebSocket>;
26
32
  /**
27
33
  * Get the message manager instance
28
34
  */
29
35
  get messageManager(): MessageManager;
36
+ /**
37
+ * Check if the WebSocket is initialized and ready
38
+ */
39
+ get isInitialized(): boolean;
30
40
  }
31
41
  declare const _default: cbws;
32
42
  export default _default;
@@ -15,6 +15,8 @@ class cbws {
15
15
  * Constructs a new cbws instance and initializes the WebSocket connection.
16
16
  */
17
17
  constructor() {
18
+ this.initialized = false;
19
+ console.log('[WebSocket] Initializing cbws instance');
18
20
  // this.websocket=undefined;
19
21
  // this.websocket = new WebSocket(`ws://localhost:${process.env.SOCKET_PORT}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${process.env.Is_Dev ? '&dev=true' : ''}`);
20
22
  // this.initializeWebSocket(initialMessage).catch(error => {
@@ -23,23 +25,29 @@ class cbws {
23
25
  }
24
26
  getUniqueConnectionId() {
25
27
  try {
28
+ console.log('[WebSocket] Reading unique connection ID from codeboltagent.yaml');
26
29
  let fileContents = fs_1.default.readFileSync('./codeboltagent.yaml', 'utf8');
27
30
  let data = js_yaml_1.default.load(fileContents);
28
- return data.unique_connectionid;
31
+ const connectionId = data.unique_connectionid;
32
+ console.log('[WebSocket] Successfully retrieved connection ID:', connectionId);
33
+ return connectionId;
29
34
  }
30
35
  catch (e) {
31
- console.error('Unable to locate codeboltagent.yaml file.');
36
+ console.error('[WebSocket] Unable to locate codeboltagent.yaml file:', e);
32
37
  return '';
33
38
  }
34
39
  }
35
40
  getInitialMessage() {
36
41
  try {
42
+ console.log('[WebSocket] Reading initial message from codeboltagent.yaml');
37
43
  let fileContents = fs_1.default.readFileSync('./codeboltagent.yaml', 'utf8');
38
44
  let data = js_yaml_1.default.load(fileContents);
39
- return data.initial_message;
45
+ const initialMessage = data.initial_message;
46
+ console.log('[WebSocket] Successfully retrieved initial message');
47
+ return initialMessage;
40
48
  }
41
49
  catch (e) {
42
- // console.error('Unable to locate codeboltagent.yaml file.');
50
+ console.warn('[WebSocket] Unable to locate codeboltagent.yaml file for initial message:', e);
43
51
  return '';
44
52
  }
45
53
  }
@@ -49,6 +57,7 @@ class cbws {
49
57
  * @returns {Promise<WebSocket>} A promise that resolves with the WebSocket instance.
50
58
  */
51
59
  async initializeWebSocket() {
60
+ console.log('[WebSocket] Starting WebSocket initialization');
52
61
  const uniqueConnectionId = this.getUniqueConnectionId();
53
62
  const initialMessage = this.getInitialMessage();
54
63
  const agentIdParam = process.env.agentId ? `&agentId=${process.env.agentId}` : '';
@@ -56,19 +65,49 @@ class cbws {
56
65
  const parentAgentInstanceIdParam = process.env.parentAgentInstanceId ? `&parentAgentInstanceId=${process.env.parentAgentInstanceId}` : '';
57
66
  const agentTask = process.env.agentTask ? `&agentTask=${process.env.agentTask}` : '';
58
67
  const socketPort = process.env.SOCKET_PORT || '12345';
59
- this.websocket = new ws_1.default(`ws://localhost:${socketPort}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${process.env.Is_Dev ? '&dev=true' : ''}`);
68
+ const wsUrl = `ws://localhost:${socketPort}/codebolt?id=${uniqueConnectionId}${agentIdParam}${parentIdParam}${parentAgentInstanceIdParam}${agentTask}${process.env.Is_Dev ? '&dev=true' : ''}`;
69
+ console.log('[WebSocket] Connecting to:', wsUrl);
70
+ this.websocket = new ws_1.default(wsUrl);
60
71
  return new Promise((resolve, reject) => {
72
+ // Set a timeout for the connection
73
+ const connectionTimeout = setTimeout(() => {
74
+ console.error('[WebSocket] Connection timeout after 10 seconds');
75
+ if (this.websocket) {
76
+ this.websocket.terminate();
77
+ }
78
+ reject(new Error('WebSocket connection timeout after 10 seconds'));
79
+ }, 10000);
61
80
  this.websocket.on('error', (error) => {
81
+ console.error('[WebSocket] Connection error:', error);
82
+ clearTimeout(connectionTimeout);
62
83
  reject(error);
63
84
  });
64
85
  this.websocket.on('open', () => {
86
+ console.log('[WebSocket] Connection opened successfully');
87
+ clearTimeout(connectionTimeout);
65
88
  // Initialize the message manager with this websocket
89
+ console.log('[WebSocket] Initializing message manager');
66
90
  messageManager_1.default.initialize(this.websocket);
91
+ this.initialized = true;
92
+ console.log('[WebSocket] WebSocket fully initialized and ready');
67
93
  resolve(this.websocket);
68
94
  });
69
- this.websocket.on('close', () => {
95
+ this.websocket.on('close', (code, reason) => {
96
+ console.log(`[WebSocket] Connection closed with code: ${code}, reason: ${reason.toString()}`);
97
+ clearTimeout(connectionTimeout);
70
98
  // Clean up pending requests when connection closes
99
+ console.log('[WebSocket] Cleaning up message manager');
71
100
  messageManager_1.default.cleanup();
101
+ this.initialized = false;
102
+ });
103
+ this.websocket.on('message', (data) => {
104
+ console.log('[WebSocket] Message received:', data.toString().substring(0, 100) + (data.toString().length > 100 ? '...' : ''));
105
+ });
106
+ this.websocket.on('ping', () => {
107
+ console.log('[WebSocket] Ping received');
108
+ });
109
+ this.websocket.on('pong', () => {
110
+ console.log('[WebSocket] Pong received');
72
111
  });
73
112
  });
74
113
  }
@@ -78,18 +117,63 @@ class cbws {
78
117
  * @throws {Error} If the WebSocket is not open.
79
118
  */
80
119
  get getWebsocket() {
81
- if (this.websocket && !this.websocket.OPEN) {
120
+ if (!this.websocket) {
121
+ console.error('[WebSocket] WebSocket is not initialized');
122
+ throw new Error('WebSocket is not initialized');
123
+ }
124
+ if (this.websocket.readyState !== ws_1.default.OPEN) {
125
+ console.error('[WebSocket] Attempted to access WebSocket but it is not open. Ready state:', this.websocket.readyState);
82
126
  throw new Error('WebSocket is not open');
83
127
  }
84
- else {
128
+ console.log('[WebSocket] WebSocket access - ready state:', this.websocket.readyState);
129
+ return this.websocket;
130
+ }
131
+ /**
132
+ * Waits for the WebSocket to be ready and returns it.
133
+ * @returns {Promise<WebSocket>} A promise that resolves with the WebSocket instance when it's ready.
134
+ */
135
+ async waitForWebSocket() {
136
+ if (!this.websocket) {
137
+ console.error('[WebSocket] WebSocket is not initialized');
138
+ throw new Error('WebSocket is not initialized');
139
+ }
140
+ if (this.websocket.readyState === ws_1.default.OPEN) {
141
+ console.log('[WebSocket] WebSocket is already open');
85
142
  return this.websocket;
86
143
  }
144
+ console.log('[WebSocket] Waiting for WebSocket to connect...');
145
+ return new Promise((resolve, reject) => {
146
+ const timeout = setTimeout(() => {
147
+ console.error('[WebSocket] Connection timeout after 5 seconds');
148
+ reject(new Error('WebSocket connection timeout'));
149
+ }, 5000);
150
+ this.websocket.once('open', () => {
151
+ console.log('[WebSocket] WebSocket connection established while waiting');
152
+ clearTimeout(timeout);
153
+ resolve(this.websocket);
154
+ });
155
+ this.websocket.once('error', (error) => {
156
+ console.error('[WebSocket] WebSocket error while waiting:', error);
157
+ clearTimeout(timeout);
158
+ reject(error);
159
+ });
160
+ });
87
161
  }
88
162
  /**
89
163
  * Get the message manager instance
90
164
  */
91
165
  get messageManager() {
166
+ if (!this.initialized) {
167
+ console.log('[WebSocket] Accessing message manager (not yet initialized)');
168
+ }
92
169
  return messageManager_1.default;
93
170
  }
171
+ /**
172
+ * Check if the WebSocket is initialized and ready
173
+ */
174
+ get isInitialized() {
175
+ return this.initialized && this.websocket && this.websocket.readyState === ws_1.default.OPEN;
176
+ }
94
177
  }
178
+ // console.log('[WebSocket] Creating cbws singleton instance');
95
179
  exports.default = new cbws();
package/dist/index.d.ts CHANGED
@@ -1,30 +1,46 @@
1
1
  /// <reference types="node" />
2
2
  import WebSocket from 'ws';
3
3
  import { EventEmitter } from 'events';
4
+ import type { ChatMessageFromUser, LLMResponse, UserMessage } from './types/socketMessageTypes';
5
+ export type { Message, ToolCall, Tool, LLMInferenceParams, APIResponse, CodeboltConfig, ProgressCallback, ErrorCallback, SuccessCallback, CompletionCallback } from './types/libFunctionTypes';
4
6
  /**
5
7
  * @class Codebolt
6
8
  * @description This class provides a unified interface to interact with various modules.
7
9
  */
8
10
  declare class Codebolt {
11
+ websocket: WebSocket | null;
12
+ private isReady;
13
+ private readyPromise;
9
14
  /**
10
15
  * @constructor
11
16
  * @description Initializes the websocket connection.
12
17
  */
13
18
  constructor();
14
19
  /**
15
- * @method waitForConnection
16
- * @description Waits for the WebSocket connection to open.
17
- * @returns {Promise<void>} A promise that resolves when the WebSocket connection is open.
20
+ * @method initializeConnection
21
+ * @description Initializes the WebSocket connection asynchronously.
22
+ * @private
18
23
  */
19
- waitForConnection(): Promise<void>;
20
- websocket: WebSocket | null;
24
+ private initializeConnection;
25
+ /**
26
+ * @method waitForReady
27
+ * @description Waits for the Codebolt instance to be fully initialized.
28
+ * @returns {Promise<void>} A promise that resolves when the instance is ready.
29
+ */
30
+ waitForReady(): Promise<void>;
31
+ /**
32
+ * @method isReady
33
+ * @description Checks if the Codebolt instance is ready for use.
34
+ * @returns {boolean} True if the instance is ready, false otherwise.
35
+ */
36
+ get ready(): boolean;
21
37
  fs: {
22
- createFile: (fileName: string, source: string, filePath: string) => Promise<import("@codebolt/types").CreateFileResponse>;
23
- createFolder: (folderName: string, folderPath: string) => Promise<import("@codebolt/types").CreateFolderResponse>;
24
- readFile: (filePath: string) => Promise<import("@codebolt/types").ReadFileResponse>;
25
- updateFile: (filename: string, filePath: string, newContent: string) => Promise<import("@codebolt/types").UpdateFileResponse>;
26
- deleteFile: (filename: string, filePath: string) => Promise<import("@codebolt/types").DeleteFileResponse>;
27
- deleteFolder: (foldername: string, folderpath: string) => Promise<import("@codebolt/types").DeleteFolderResponse>;
38
+ createFile: (fileName: string, source: string, filePath: string) => Promise<import("./types/socketMessageTypes").CreateFileResponse>;
39
+ createFolder: (folderName: string, folderPath: string) => Promise<import("./types/socketMessageTypes").CreateFolderResponse>;
40
+ readFile: (filePath: string) => Promise<import("./types/socketMessageTypes").ReadFileResponse>;
41
+ updateFile: (filename: string, filePath: string, newContent: string) => Promise<import("./types/socketMessageTypes").UpdateFileResponse>;
42
+ deleteFile: (filename: string, filePath: string) => Promise<import("./types/socketMessageTypes").DeleteFileResponse>;
43
+ deleteFolder: (foldername: string, folderpath: string) => Promise<import("./types/socketMessageTypes").DeleteFolderResponse>;
28
44
  listFile: (folderPath: string, isRecursive?: boolean) => Promise<any>;
29
45
  listCodeDefinitionNames: (path: string) => Promise<{
30
46
  success: boolean;
@@ -49,45 +65,45 @@ declare class Codebolt {
49
65
  }>;
50
66
  };
51
67
  git: {
52
- init: (path: string) => Promise<any>;
53
- pull: () => Promise<any>;
54
- push: () => Promise<any>;
55
- status: () => Promise<any>;
56
- addAll: () => Promise<any>;
57
- commit: (message: string) => Promise<any>;
58
- checkout: (branch: string) => Promise<any>;
59
- branch: (branch: string) => Promise<any>;
60
- logs: (path: string) => Promise<any>;
61
- diff: (commitHash: string) => Promise<any>;
68
+ init: (path: string) => Promise<import("./types/socketMessageTypes").GitInitResponse>;
69
+ pull: () => Promise<import("./types/socketMessageTypes").GitPullResponse>;
70
+ push: () => Promise<import("./types/socketMessageTypes").GitPushResponse>;
71
+ status: () => Promise<import("./types/socketMessageTypes").GitStatusResponse>;
72
+ addAll: () => Promise<import("./types/socketMessageTypes").AddResponse>;
73
+ commit: (message: string) => Promise<import("./types/socketMessageTypes").GitCommitResponse>;
74
+ checkout: (branch: string) => Promise<import("./types/socketMessageTypes").GitCheckoutResponse>;
75
+ branch: (branch: string) => Promise<import("./types/socketMessageTypes").GitBranchResponse>;
76
+ logs: (path: string) => Promise<import("./types/socketMessageTypes").GitLogsResponse>;
77
+ diff: (commitHash: string) => Promise<import("./types/socketMessageTypes").GitDiffResponse>;
62
78
  };
63
79
  llm: {
64
- inference: (message: string, llmrole: string) => Promise<import("@codebolt/types").LLMResponse>;
80
+ inference: (message: string, llmrole: string) => Promise<LLMResponse>;
65
81
  };
66
82
  browser: {
67
- newPage: () => Promise<any>;
68
- getUrl: () => Promise<import("@codebolt/types").UrlResponse>;
69
- goToPage: (url: string) => Promise<import("@codebolt/types").GoToPageResponse>;
70
- screenshot: () => Promise<any>;
71
- getHTML: () => Promise<import("@codebolt/types").HtmlReceived>;
72
- getMarkdown: () => Promise<import("@codebolt/types").GetMarkdownResponse>;
83
+ newPage: () => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
84
+ getUrl: () => Promise<import("./types/socketMessageTypes").UrlResponse>;
85
+ goToPage: (url: string) => Promise<import("./types/socketMessageTypes").GoToPageResponse>;
86
+ screenshot: () => Promise<import("./types/socketMessageTypes").BrowserScreenshotResponse>;
87
+ getHTML: () => Promise<import("./types/socketMessageTypes").HtmlReceived>;
88
+ getMarkdown: () => Promise<import("./types/socketMessageTypes").GetMarkdownResponse>;
73
89
  getPDF: () => void;
74
90
  pdfToText: () => void;
75
- getContent: () => Promise<import("@codebolt/types").GetContentResponse>;
76
- getSnapShot: () => Promise<any>;
77
- getBrowserInfo: () => Promise<any>;
78
- extractText: () => Promise<import("@codebolt/types").ExtractTextResponse>;
91
+ getContent: () => Promise<import("./types/socketMessageTypes").GetContentResponse>;
92
+ getSnapShot: () => Promise<import("./types/socketMessageTypes").BrowserSnapshotResponse>;
93
+ getBrowserInfo: () => Promise<import("./types/socketMessageTypes").BrowserInfoResponse>;
94
+ extractText: () => Promise<import("./types/socketMessageTypes").ExtractTextResponse>;
79
95
  close: () => void;
80
- scroll: (direction: string, pixels: string) => Promise<any>;
81
- type: (elementid: string, text: string) => Promise<any>;
82
- click: (elementid: string) => Promise<any>;
83
- enter: () => Promise<any>;
84
- search: (elementid: string, query: string) => Promise<any>;
96
+ scroll: (direction: string, pixels: string) => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
97
+ type: (elementid: string, text: string) => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
98
+ click: (elementid: string) => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
99
+ enter: () => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
100
+ search: (elementid: string, query: string) => Promise<import("./types/socketMessageTypes").BrowserActionResponseData>;
85
101
  };
86
102
  chat: {
87
- getChatHistory: () => Promise<import("@codebolt/types").ChatMessage[]>;
103
+ getChatHistory: () => Promise<import("./types/socketMessageTypes").ChatMessage[]>;
88
104
  setRequestHandler: (handler: (request: any, response: (data: any) => void) => void | Promise<void>) => void;
89
105
  sendMessage: (message: string, payload: any) => void;
90
- waitforReply: (message: string) => Promise<import("@codebolt/types").UserMessage>;
106
+ waitforReply: (message: string) => Promise<UserMessage>;
91
107
  processStarted: (onStopClicked?: ((message: any) => void) | undefined) => {
92
108
  stopProcess: () => void;
93
109
  cleanup: () => void;
@@ -99,7 +115,7 @@ declare class Codebolt {
99
115
  processFinished: () => void;
100
116
  sendConfirmationRequest: (confirmationMessage: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
101
117
  askQuestion: (question: string, buttons?: string[], withFeedback?: boolean) => Promise<string>;
102
- sendNotificationEvent: (notificationMessage: string, type: "debug" | "git" | "planner" | "browser" | "editor" | "terminal" | "preview") => void;
118
+ sendNotificationEvent: (notificationMessage: string, type: "browser" | "terminal" | "git" | "debug" | "planner" | "editor" | "preview") => void;
103
119
  };
104
120
  terminal: {
105
121
  eventEmitter: {
@@ -122,8 +138,8 @@ declare class Codebolt {
122
138
  eventNames(): (string | symbol)[];
123
139
  };
124
140
  executeCommand: (command: string, returnEmptyStringOnSuccess?: boolean) => Promise<any>;
125
- executeCommandRunUntilError: (command: string, executeInMain?: boolean) => Promise<import("@codebolt/types").CommandError>;
126
- sendManualInterrupt(): Promise<import("@codebolt/types").TerminalInterruptResponse>;
141
+ executeCommandRunUntilError: (command: string, executeInMain?: boolean) => Promise<import("./types/socketMessageTypes").CommandError>;
142
+ sendManualInterrupt(): Promise<import("./types/socketMessageTypes").TerminalInterruptResponse>;
127
143
  executeCommandWithStream(command: string, executeInMain?: boolean): {
128
144
  cleanup?: (() => void) | undefined;
129
145
  [EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: any[]): void;
@@ -145,11 +161,11 @@ declare class Codebolt {
145
161
  };
146
162
  };
147
163
  codeutils: {
148
- getJsTree: (filePath?: string | undefined) => Promise<import("./modules/codeutils").JSTreeResponse>;
164
+ getJsTree: (filePath?: string | undefined) => Promise<import("./types/InternalTypes").JSTreeResponse>;
149
165
  getAllFilesAsMarkDown: () => Promise<string>;
150
- performMatch: (matcherDefinition: object, problemPatterns: any[], problems?: any[]) => Promise<import("@codebolt/types").MatchProblemResponse>;
151
- getMatcherList: () => Promise<import("@codebolt/types").GetMatcherListTreeResponse>;
152
- matchDetail: (matcher: string) => Promise<import("@codebolt/types").getMatchDetail>;
166
+ performMatch: (matcherDefinition: object, problemPatterns: any[], problems?: any[]) => Promise<import("./types/socketMessageTypes").MatchProblemResponse>;
167
+ getMatcherList: () => Promise<import("./types/socketMessageTypes").GetMatcherListTreeResponse>;
168
+ matchDetail: (matcher: string) => Promise<import("./types/socketMessageTypes").getMatchDetail>;
153
169
  };
154
170
  crawler: {
155
171
  start: () => void;
@@ -183,7 +199,7 @@ declare class Codebolt {
183
199
  class: string;
184
200
  location: string;
185
201
  }[]>;
186
- getAstTreeInFile: (file: string, className?: string | undefined) => Promise<import("./modules/codeparsers").ASTNode | {
202
+ getAstTreeInFile: (file: string, className?: string | undefined) => Promise<import("./types/commonTypes").ASTNode | {
187
203
  error: string;
188
204
  }>;
189
205
  };
@@ -198,11 +214,7 @@ declare class Codebolt {
198
214
  parsed?: any;
199
215
  };
200
216
  parseCSV: (csvString: string) => {
201
- success: boolean; /**
202
- * @method waitForConnection
203
- * @description Waits for the WebSocket connection to open.
204
- * @returns {Promise<void>} A promise that resolves when the WebSocket connection is open.
205
- */
217
+ success: boolean;
206
218
  parsed?: any[] | undefined;
207
219
  error?: Error | undefined;
208
220
  };
@@ -215,23 +227,19 @@ declare class Codebolt {
215
227
  };
216
228
  project: {
217
229
  getProjectSettings: () => Promise<any>;
218
- getProjectPath: () => Promise<import("@codebolt/types").GetProjectPathResponse>;
219
- getRepoMap: (message: any) => Promise<import("@codebolt/types").GetProjectPathResponse>;
220
- runProject: () => void; /**
221
- * @method waitForConnection
222
- * @description Waits for the WebSocket connection to open.
223
- * @returns {Promise<void>} A promise that resolves when the WebSocket connection is open.
224
- */
230
+ getProjectPath: () => Promise<import("./types/socketMessageTypes").GetProjectPathResponse>;
231
+ getRepoMap: (message: any) => Promise<import("./types/socketMessageTypes").GetProjectPathResponse>;
232
+ runProject: () => void;
225
233
  getEditorFileStatus: () => Promise<any>;
226
234
  };
227
235
  dbmemory: {
228
- addKnowledge: (key: string, value: any) => Promise<import("@codebolt/types").MemorySetResponse>;
229
- getKnowledge: (key: string) => Promise<import("@codebolt/types").MemoryGetResponse>;
236
+ addKnowledge: (key: string, value: any) => Promise<import("./types/socketMessageTypes").MemorySetResponse>;
237
+ getKnowledge: (key: string) => Promise<import("./types/socketMessageTypes").MemoryGetResponse>;
230
238
  };
231
239
  cbstate: {
232
- getApplicationState: () => Promise<import("@codebolt/types").ApplicationState>;
233
- addToAgentState: (key: string, value: string) => Promise<import("@codebolt/types").AddToAgentStateResponse>;
234
- getAgentState: () => Promise<import("@codebolt/types").GetAgentStateResponse>;
240
+ getApplicationState: () => Promise<import("./types/commonTypes").ApplicationState>;
241
+ addToAgentState: (key: string, value: string) => Promise<import("./types/socketMessageTypes").AddToAgentStateResponse>;
242
+ getAgentState: () => Promise<import("./types/socketMessageTypes").GetAgentStateResponse>;
235
243
  getProjectState: () => Promise<any>;
236
244
  updateProjectState: (key: string, value: any) => Promise<any>;
237
245
  };
@@ -241,60 +249,54 @@ declare class Codebolt {
241
249
  updateTask: (task: string) => Promise<any>;
242
250
  };
243
251
  vectordb: {
244
- getVector: (key: string) => Promise<import("@codebolt/types").GetVectorResponse>;
245
- addVectorItem: (item: any) => Promise<import("@codebolt/types").AddVectorItemResponse>;
246
- queryVectorItem: (key: string) => Promise<import("@codebolt/types").QueryVectorItemResponse>;
247
- queryVectorItems: (items: [], dbPath: string) => Promise<import("@codebolt/types").QueryVectorItemResponse>;
252
+ getVector: (key: string) => Promise<import("./types/socketMessageTypes").GetVectorResponse>;
253
+ addVectorItem: (item: any) => Promise<import("./types/socketMessageTypes").AddVectorItemResponse>;
254
+ queryVectorItem: (key: string) => Promise<import("./types/socketMessageTypes").QueryVectorItemResponse>;
255
+ queryVectorItems: (items: [], dbPath: string) => Promise<import("./types/socketMessageTypes").QueryVectorItemResponse>;
248
256
  };
249
257
  debug: {
250
- debug: (log: string, type: import("./modules/debug").logType) => Promise<import("@codebolt/types").DebugAddLogResponse>;
251
- openDebugBrowser: (url: string, port: number) => Promise<import("@codebolt/types").OpenDebugBrowserResponse>;
258
+ debug: (log: string, type: import("./modules/debug").logType) => Promise<import("./types/socketMessageTypes").DebugAddLogResponse>;
259
+ openDebugBrowser: (url: string, port: number) => Promise<import("./types/socketMessageTypes").OpenDebugBrowserResponse>;
252
260
  };
253
261
  tokenizer: {
254
- addToken: (key: string) => Promise<import("@codebolt/types").AddTokenResponse>;
255
- getToken: (key: string) => Promise<import("@codebolt/types").GetTokenResponse>;
262
+ addToken: (key: string) => Promise<import("./types/socketMessageTypes").AddTokenResponse>;
263
+ getToken: (key: string) => Promise<import("./types/socketMessageTypes").GetTokenResponse>;
256
264
  };
257
265
  chatSummary: {
258
- summarizeAll: () => Promise<{
259
- role: string;
260
- content: string;
261
- }[]>;
266
+ summarizeAll: () => Promise<import("./types/socketMessageTypes").GetSummarizeAllResponse>;
262
267
  summarize: (messages: {
263
268
  role: string;
264
269
  content: string;
265
- }[], depth: number) => Promise<{
266
- role: string;
267
- content: string;
268
- }[]>;
270
+ }[], depth: number) => Promise<import("./types/socketMessageTypes").GetSummarizeResponse>;
269
271
  };
270
- tools: {
271
- getEnabledToolBoxes: () => Promise<any>;
272
- getLocalToolBoxes: () => Promise<any>;
273
- getMentionedToolBoxes: (userMessage: import("./utils").UserMessage) => Promise<any>;
274
- searchAvailableToolBoxes: (query: string) => Promise<any>;
275
- listToolsFromToolBoxes: (toolBoxes: string[]) => Promise<any>;
276
- configureToolBox: (name: string, config: any) => Promise<any>;
272
+ mcp: {
273
+ getEnabledMCPServers: () => Promise<import("./types/socketMessageTypes").GetEnabledToolBoxesResponse>;
274
+ getLocalMCPServers: () => Promise<import("./types/socketMessageTypes").GetLocalToolBoxesResponse>;
275
+ getMentionedMCPServers: (userMessage: import("./utils").UserMessage) => Promise<import("./types/socketMessageTypes").GetAvailableToolBoxesResponse>;
276
+ searchAvailableMCPServers: (query: string) => Promise<import("./types/socketMessageTypes").SearchAvailableToolBoxesResponse>;
277
+ listMcpFromServers: (toolBoxes: string[]) => Promise<import("./types/socketMessageTypes").ListToolsFromToolBoxesResponse>;
278
+ configureMCPServer: (name: string, config: any) => Promise<import("./types/socketMessageTypes").ConfigureToolBoxResponse>;
277
279
  getTools: (tools: {
278
280
  toolbox: string;
279
281
  toolName: string;
280
- }[]) => Promise<any[]>;
281
- executeTool: (toolbox: string, toolName: string, params: any) => Promise<any>;
282
+ }[]) => Promise<import("./types/socketMessageTypes").GetToolsResponse>;
283
+ executeTool: (toolbox: string, toolName: string, params: any) => Promise<import("./types/socketMessageTypes").ExecuteToolResponse>;
282
284
  };
283
285
  agent: {
284
- findAgent: (task: string, maxResult: number | undefined, agents: never[] | undefined, agentLocaltion: import("./modules/agent").AgentLocation | undefined, getFrom: import("./modules/agent").FilterUsing.USE_VECTOR_DB) => Promise<any>;
285
- startAgent: (agentId: string, task: string) => Promise<any>;
286
- getAgentsList: (type?: import("./modules/agent").Agents) => Promise<any>;
287
- getAgentsDetail: (agentList?: never[]) => Promise<any>;
286
+ findAgent: (task: string, maxResult: number | undefined, agents: never[] | undefined, agentLocaltion: import("./modules/agent").AgentLocation | undefined, getFrom: import("./modules/agent").FilterUsing.USE_VECTOR_DB) => Promise<import("./types/socketMessageTypes").FindAgentByTaskResponse>;
287
+ startAgent: (agentId: string, task: string) => Promise<import("./types/socketMessageTypes").TaskCompletionResponse>;
288
+ getAgentsList: (type?: import("./modules/agent").Agents) => Promise<import("./types/socketMessageTypes").ListAgentsResponse>;
289
+ getAgentsDetail: (agentList?: never[]) => Promise<import("./types/socketMessageTypes").AgentsDetailResponse>;
288
290
  };
289
291
  utils: {
290
- editFileAndApplyDiff: (filePath: string, diff: string, diffIdentifier: string, prompt: string, applyModel?: string | undefined) => Promise<any>;
292
+ editFileAndApplyDiff: (filePath: string, diff: string, diffIdentifier: string, prompt: string, applyModel?: string | undefined) => Promise<import("./types/socketMessageTypes").FsEditFileAndApplyDiffResponse>;
291
293
  };
292
294
  /**
293
295
  * Sets up a listener for incoming messages with a direct handler function.
294
296
  * @param {Function} handler - The handler function to call when a message is received.
295
297
  * @returns {void}
296
298
  */
297
- onMessage(handler: (userMessage: any) => void | Promise<void> | any | Promise<any>): void;
299
+ onMessage(handler: (userMessage: ChatMessageFromUser) => void | Promise<void> | any | Promise<any>): void;
298
300
  }
299
301
  declare const codebolt: Codebolt;
300
302
  export default codebolt;