@codebolt/codeboltjs 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/Readme.md +3 -0
  2. package/dist/core/Codebolt.d.ts +212 -165
  3. package/dist/core/Codebolt.js +267 -6
  4. package/dist/core/websocket.js +9 -11
  5. package/dist/index.d.ts +1 -1
  6. package/dist/modules/agent.d.ts +2 -16
  7. package/dist/modules/agent.js +15 -33
  8. package/dist/modules/browser.d.ts +1 -1
  9. package/dist/modules/browser.js +52 -51
  10. package/dist/modules/chat.d.ts +2 -2
  11. package/dist/modules/chat.js +20 -18
  12. package/dist/modules/codeutils.d.ts +1 -9
  13. package/dist/modules/codeutils.js +13 -111
  14. package/dist/modules/dbmemory.d.ts +3 -3
  15. package/dist/modules/dbmemory.js +8 -7
  16. package/dist/modules/debug.d.ts +1 -1
  17. package/dist/modules/fs.d.ts +59 -28
  18. package/dist/modules/fs.js +86 -45
  19. package/dist/modules/git.d.ts +1 -1
  20. package/dist/modules/git.js +31 -30
  21. package/dist/modules/history.d.ts +1 -1
  22. package/dist/modules/history.js +7 -6
  23. package/dist/modules/llm.d.ts +13 -20
  24. package/dist/modules/llm.js +16 -15
  25. package/dist/modules/mcp.d.ts +4 -4
  26. package/dist/modules/mcp.js +25 -25
  27. package/dist/modules/outputparsers.d.ts +22 -22
  28. package/dist/modules/outputparsers.js +7 -5
  29. package/dist/modules/project.d.ts +1 -1
  30. package/dist/modules/project.js +15 -13
  31. package/dist/modules/state.d.ts +1 -1
  32. package/dist/modules/state.js +16 -15
  33. package/dist/modules/task.d.ts +136 -92
  34. package/dist/modules/task.js +354 -205
  35. package/dist/modules/terminal.d.ts +1 -1
  36. package/dist/modules/terminal.js +12 -11
  37. package/dist/modules/tokenizer.d.ts +1 -1
  38. package/dist/modules/tokenizer.js +7 -6
  39. package/dist/modules/user-message-manager.d.ts +165 -0
  40. package/dist/modules/user-message-manager.js +308 -0
  41. package/dist/modules/user-message-utilities.d.ts +111 -0
  42. package/dist/modules/user-message-utilities.js +115 -0
  43. package/dist/modules/utils.d.ts +1 -1
  44. package/dist/modules/utils.js +4 -3
  45. package/dist/modules/vectordb.d.ts +1 -1
  46. package/dist/modules/vectordb.js +13 -12
  47. package/dist/notificationfunctions/agent.js +7 -6
  48. package/dist/notificationfunctions/browser.js +9 -8
  49. package/dist/notificationfunctions/chat.js +9 -8
  50. package/dist/notificationfunctions/codeutils.js +9 -8
  51. package/dist/notificationfunctions/crawler.js +9 -8
  52. package/dist/notificationfunctions/dbmemory.js +9 -8
  53. package/dist/notificationfunctions/fs.js +45 -44
  54. package/dist/notificationfunctions/git.d.ts +2 -2
  55. package/dist/notificationfunctions/git.js +111 -51
  56. package/dist/notificationfunctions/history.js +9 -8
  57. package/dist/notificationfunctions/llm.js +9 -8
  58. package/dist/notificationfunctions/mcp.js +17 -16
  59. package/dist/notificationfunctions/search.js +13 -12
  60. package/dist/notificationfunctions/system.js +5 -4
  61. package/dist/notificationfunctions/terminal.js +5 -4
  62. package/dist/notificationfunctions/todo.js +13 -12
  63. package/dist/types/commonTypes.d.ts +4 -0
  64. package/dist/types/index.d.ts +1 -1
  65. package/dist/types/libFunctionTypes.d.ts +918 -29
  66. package/dist/types/libFunctionTypes.js +33 -0
  67. package/dist/types/notificationFunctions/git.d.ts +40 -1
  68. package/dist/types/notificationFunctions/index.d.ts +1 -0
  69. package/dist/types/notificationFunctions/index.js +1 -0
  70. package/package.json +17 -25
  71. package/dist/modules/codeparsers.d.ts +0 -37
  72. package/dist/modules/codeparsers.js +0 -329
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const websocket_1 = __importDefault(require("../core/websocket"));
7
+ const enum_1 = require("@codebolt/types/enum");
7
8
  /**
8
9
  * A module for interacting with a browser through WebSockets.
9
10
  */
@@ -13,9 +14,9 @@ const cbbrowser = {
13
14
  */
14
15
  newPage: () => {
15
16
  return websocket_1.default.messageManager.sendAndWaitForResponse({
16
- "type": "browserEvent",
17
- action: 'newPage'
18
- }, "newPageResponse");
17
+ "type": enum_1.EventType.BROWSER_EVENT,
18
+ action: enum_1.BrowserAction.NEW_PAGE
19
+ }, enum_1.BrowserResponseType.NEW_PAGE_RESPONSE);
19
20
  },
20
21
  /**
21
22
  * Retrieves the current URL of the browser's active page.
@@ -23,9 +24,9 @@ const cbbrowser = {
23
24
  */
24
25
  getUrl: () => {
25
26
  return websocket_1.default.messageManager.sendAndWaitForResponse({
26
- "type": "browserEvent",
27
- action: 'getUrl'
28
- }, "getUrlResponse");
27
+ "type": enum_1.EventType.BROWSER_EVENT,
28
+ action: enum_1.BrowserAction.GET_URL
29
+ }, enum_1.BrowserResponseType.GET_URL_RESPONSE);
29
30
  },
30
31
  /**
31
32
  * Navigates to a specified URL.
@@ -34,19 +35,19 @@ const cbbrowser = {
34
35
  */
35
36
  goToPage: (url) => {
36
37
  return websocket_1.default.messageManager.sendAndWaitForResponse({
37
- "type": "browserEvent",
38
- action: 'goToPage',
38
+ "type": enum_1.EventType.BROWSER_EVENT,
39
+ action: enum_1.BrowserAction.GO_TO_PAGE,
39
40
  url
40
- }, "goToPageResponse");
41
+ }, enum_1.BrowserResponseType.GO_TO_PAGE_RESPONSE);
41
42
  },
42
43
  /**
43
44
  * Takes a screenshot of the current page.
44
45
  */
45
46
  screenshot: () => {
46
47
  return websocket_1.default.messageManager.sendAndWaitForResponse({
47
- "type": "browserEvent",
48
- action: 'screenshot'
49
- }, "screenshotResponse");
48
+ "type": enum_1.EventType.BROWSER_EVENT,
49
+ action: enum_1.BrowserAction.SCREENSHOT
50
+ }, enum_1.BrowserResponseType.SCREENSHOT_RESPONSE);
50
51
  },
51
52
  /**
52
53
  * Retrieves the HTML content of the current page.
@@ -54,9 +55,9 @@ const cbbrowser = {
54
55
  */
55
56
  getHTML: () => {
56
57
  return websocket_1.default.messageManager.sendAndWaitForResponse({
57
- "type": "browserEvent",
58
- action: 'getHTML'
59
- }, "htmlReceived");
58
+ "type": enum_1.EventType.BROWSER_EVENT,
59
+ action: enum_1.BrowserAction.GET_HTML
60
+ }, enum_1.BrowserResponseType.HTML_RECEIVED);
60
61
  },
61
62
  /**
62
63
  * Retrieves the Markdown content of the current page.
@@ -64,9 +65,9 @@ const cbbrowser = {
64
65
  */
65
66
  getMarkdown: () => {
66
67
  return websocket_1.default.messageManager.sendAndWaitForResponse({
67
- "type": "browserEvent",
68
- action: 'getMarkdown'
69
- }, "getMarkdownResponse");
68
+ "type": enum_1.EventType.BROWSER_EVENT,
69
+ action: enum_1.BrowserAction.GET_MARKDOWN
70
+ }, enum_1.BrowserResponseType.GET_MARKDOWN_RESPONSE);
70
71
  },
71
72
  /**
72
73
  * Retrieves the PDF content of the current page.
@@ -74,8 +75,8 @@ const cbbrowser = {
74
75
  */
75
76
  getPDF: () => {
76
77
  websocket_1.default.messageManager.send({
77
- "type": "browserEvent",
78
- action: 'getPDF'
78
+ "type": enum_1.EventType.BROWSER_EVENT,
79
+ action: enum_1.BrowserAction.GET_PDF
79
80
  });
80
81
  },
81
82
  /**
@@ -83,8 +84,8 @@ const cbbrowser = {
83
84
  */
84
85
  pdfToText: () => {
85
86
  websocket_1.default.messageManager.send({
86
- "type": "browserEvent",
87
- action: 'pdfToText'
87
+ "type": enum_1.EventType.BROWSER_EVENT,
88
+ action: enum_1.BrowserAction.PDF_TO_TEXT
88
89
  });
89
90
  },
90
91
  /**
@@ -93,9 +94,9 @@ const cbbrowser = {
93
94
  */
94
95
  getContent: () => {
95
96
  return websocket_1.default.messageManager.sendAndWaitForResponse({
96
- "type": "browserEvent",
97
- action: 'getContent'
98
- }, "getContentResponse");
97
+ "type": enum_1.EventType.BROWSER_EVENT,
98
+ action: enum_1.BrowserAction.GET_CONTENT
99
+ }, enum_1.BrowserResponseType.GET_CONTENT_RESPONSE);
99
100
  },
100
101
  /**
101
102
  * Retrieves the snapshot of the current page.
@@ -103,9 +104,9 @@ const cbbrowser = {
103
104
  */
104
105
  getSnapShot: () => {
105
106
  return websocket_1.default.messageManager.sendAndWaitForResponse({
106
- "type": "browserEvent",
107
- action: 'getSnapShot'
108
- }, "getSnapShotResponse");
107
+ "type": enum_1.EventType.BROWSER_EVENT,
108
+ action: enum_1.BrowserAction.GET_SNAPSHOT
109
+ }, enum_1.BrowserResponseType.GET_SNAPSHOT_RESPONSE);
109
110
  },
110
111
  /**
111
112
  * Retrieves browser info like height width scrollx scrolly of the current page.
@@ -113,9 +114,9 @@ const cbbrowser = {
113
114
  */
114
115
  getBrowserInfo: () => {
115
116
  return websocket_1.default.messageManager.sendAndWaitForResponse({
116
- "type": "browserEvent",
117
- action: 'getBrowserInfo'
118
- }, "getBrowserInfoResponse");
117
+ "type": enum_1.EventType.BROWSER_EVENT,
118
+ action: enum_1.BrowserAction.GET_BROWSER_INFO
119
+ }, enum_1.BrowserResponseType.GET_BROWSER_INFO_RESPONSE);
119
120
  },
120
121
  /**
121
122
  * Extracts text from the current page.
@@ -124,17 +125,17 @@ const cbbrowser = {
124
125
  */
125
126
  extractText: () => {
126
127
  return websocket_1.default.messageManager.sendAndWaitForResponse({
127
- "type": "browserEvent",
128
- action: 'extractText'
129
- }, "extractTextResponse");
128
+ "type": enum_1.EventType.BROWSER_EVENT,
129
+ action: enum_1.BrowserAction.EXTRACT_TEXT
130
+ }, enum_1.BrowserResponseType.EXTRACT_TEXT_RESPONSE);
130
131
  },
131
132
  /**
132
133
  * Closes the current page.
133
134
  */
134
135
  close: () => {
135
136
  websocket_1.default.messageManager.send({
136
- "type": "browserEvent",
137
- action: 'close'
137
+ "type": enum_1.EventType.BROWSER_EVENT,
138
+ action: enum_1.BrowserAction.CLOSE
138
139
  });
139
140
  },
140
141
  /**
@@ -145,11 +146,11 @@ const cbbrowser = {
145
146
  */
146
147
  scroll: (direction, pixels) => {
147
148
  return websocket_1.default.messageManager.sendAndWaitForResponse({
148
- "type": "browserEvent",
149
- action: 'scroll',
149
+ "type": enum_1.EventType.BROWSER_EVENT,
150
+ action: enum_1.BrowserAction.SCROLL,
150
151
  direction,
151
152
  pixels
152
- }, "scrollResponse");
153
+ }, enum_1.BrowserResponseType.SCROLL_RESPONSE);
153
154
  },
154
155
  /**
155
156
  * Types text into a specified element on the page.
@@ -159,11 +160,11 @@ const cbbrowser = {
159
160
  */
160
161
  type: (elementid, text) => {
161
162
  return websocket_1.default.messageManager.sendAndWaitForResponse({
162
- "type": "browserEvent",
163
- action: 'type',
163
+ "type": enum_1.EventType.BROWSER_EVENT,
164
+ action: enum_1.BrowserAction.TYPE,
164
165
  text,
165
166
  elementid
166
- }, "typeResponse");
167
+ }, enum_1.BrowserResponseType.TYPE_RESPONSE);
167
168
  },
168
169
  /**
169
170
  * Clicks on a specified element on the page.
@@ -172,10 +173,10 @@ const cbbrowser = {
172
173
  */
173
174
  click: (elementid) => {
174
175
  return websocket_1.default.messageManager.sendAndWaitForResponse({
175
- "type": "browserEvent",
176
- action: 'click',
176
+ "type": enum_1.EventType.BROWSER_EVENT,
177
+ action: enum_1.BrowserAction.CLICK,
177
178
  elementid
178
- }, "clickResponse");
179
+ }, enum_1.BrowserResponseType.CLICK_RESPONSE);
179
180
  },
180
181
  /**
181
182
  * Simulates the Enter key press on the current page.
@@ -183,9 +184,9 @@ const cbbrowser = {
183
184
  */
184
185
  enter: () => {
185
186
  return websocket_1.default.messageManager.sendAndWaitForResponse({
186
- "type": "browserEvent",
187
- action: 'enter'
188
- }, "EnterResponse");
187
+ "type": enum_1.EventType.BROWSER_EVENT,
188
+ action: enum_1.BrowserAction.ENTER
189
+ }, enum_1.BrowserResponseType.ENTER_RESPONSE);
189
190
  },
190
191
  /**
191
192
  * Performs a search on the current page using a specified query.
@@ -195,11 +196,11 @@ const cbbrowser = {
195
196
  */
196
197
  search: (elementid, query) => {
197
198
  return websocket_1.default.messageManager.sendAndWaitForResponse({
198
- "type": "browserEvent",
199
- action: 'search',
199
+ "type": enum_1.EventType.BROWSER_EVENT,
200
+ action: enum_1.BrowserAction.SEARCH,
200
201
  elementid,
201
202
  query
202
- }, "searchResponse");
203
+ }, enum_1.BrowserResponseType.SEARCH_RESPONSE);
203
204
  }
204
205
  };
205
206
  exports.default = cbbrowser;
@@ -1,4 +1,4 @@
1
- import { ChatMessage, UserMessage } from '../types/socketMessageTypes';
1
+ import { ChatMessage, UserMessage } from '@codebolt/types/sdk';
2
2
  type RequestHandler = (request: any, response: (data: any) => void) => Promise<void> | void;
3
3
  /**
4
4
  * Chat module to interact with the WebSocket server.
@@ -8,7 +8,7 @@ declare const cbchat: {
8
8
  * Retrieves the chat history from the server.
9
9
  * @returns {Promise<ChatMessage[]>} A promise that resolves with an array of ChatMessage objects representing the chat history.
10
10
  */
11
- getChatHistory: () => Promise<ChatMessage[]>;
11
+ getChatHistory: (threadId: string) => Promise<ChatMessage>;
12
12
  /**
13
13
  * Sets a global request handler for all incoming messages
14
14
  * @param handler The async handler function
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  // chat.ts
7
7
  const websocket_1 = __importDefault(require("../core/websocket"));
8
+ const enum_1 = require("@codebolt/types/enum");
8
9
  /**
9
10
  * Chat module to interact with the WebSocket server.
10
11
  */
@@ -13,10 +14,11 @@ const cbchat = {
13
14
  * Retrieves the chat history from the server.
14
15
  * @returns {Promise<ChatMessage[]>} A promise that resolves with an array of ChatMessage objects representing the chat history.
15
16
  */
16
- getChatHistory: () => {
17
+ getChatHistory: (threadId) => {
17
18
  return websocket_1.default.messageManager.sendAndWaitForResponse({
18
- "type": "getChatHistory"
19
- }, "getChatHistoryResponse");
19
+ "type": enum_1.ChatEventType.GET_CHAT_HISTORY,
20
+ threadId
21
+ }, enum_1.ChatResponseType.GET_CHAT_HISTORY_RESPONSE);
20
22
  },
21
23
  /**
22
24
  * Sets a global request handler for all incoming messages
@@ -30,7 +32,7 @@ const cbchat = {
30
32
  try {
31
33
  await handler(request, (responseData) => {
32
34
  websocket_1.default.messageManager.send({
33
- type: `processStoped`,
35
+ type: enum_1.ChatEventType.PROCESS_STOPPED,
34
36
  ...responseData
35
37
  });
36
38
  });
@@ -54,7 +56,7 @@ const cbchat = {
54
56
  */
55
57
  sendMessage: (message, payload) => {
56
58
  websocket_1.default.messageManager.send({
57
- "type": "sendMessage",
59
+ "type": enum_1.ChatEventType.SEND_MESSAGE,
58
60
  "message": message,
59
61
  payload
60
62
  });
@@ -66,9 +68,9 @@ const cbchat = {
66
68
  */
67
69
  waitforReply: (message) => {
68
70
  return websocket_1.default.messageManager.sendAndWaitForResponse({
69
- "type": "waitforReply",
71
+ "type": enum_1.ChatEventType.WAIT_FOR_REPLY,
70
72
  "message": message
71
- }, "waitFormessageResponse");
73
+ }, enum_1.ChatResponseType.WAIT_FOR_MESSAGE_RESPONSE);
72
74
  },
73
75
  /**
74
76
  * Notifies the server that a process has started and sets up a listener for stopProcessClicked events.
@@ -78,12 +80,12 @@ const cbchat = {
78
80
  processStarted: (onStopClicked) => {
79
81
  // Send the process started message
80
82
  websocket_1.default.messageManager.send({
81
- "type": "processStarted"
83
+ "type": enum_1.ChatEventType.PROCESS_STARTED
82
84
  });
83
85
  // Register event listener for WebSocket messages if callback provided
84
86
  if (onStopClicked) {
85
87
  const handleStopMessage = (message) => {
86
- if (message.type === 'stopProcessClicked') {
88
+ if (message.type === enum_1.ChatEventType.STOP_PROCESS_CLICKED) {
87
89
  onStopClicked(message);
88
90
  }
89
91
  };
@@ -92,7 +94,7 @@ const cbchat = {
92
94
  return {
93
95
  stopProcess: () => {
94
96
  websocket_1.default.messageManager.send({
95
- "type": "processStoped"
97
+ "type": enum_1.ChatEventType.PROCESS_STOPPED
96
98
  });
97
99
  },
98
100
  cleanup: () => {
@@ -104,7 +106,7 @@ const cbchat = {
104
106
  return {
105
107
  stopProcess: () => {
106
108
  websocket_1.default.messageManager.send({
107
- "type": "processStoped"
109
+ "type": enum_1.ChatEventType.PROCESS_STOPPED
108
110
  });
109
111
  }
110
112
  };
@@ -115,7 +117,7 @@ const cbchat = {
115
117
  */
116
118
  stopProcess: () => {
117
119
  websocket_1.default.messageManager.send({
118
- "type": "processStoped"
120
+ "type": enum_1.ChatEventType.PROCESS_STOPPED
119
121
  });
120
122
  },
121
123
  /**
@@ -124,7 +126,7 @@ const cbchat = {
124
126
  */
125
127
  processFinished: () => {
126
128
  websocket_1.default.messageManager.send({
127
- "type": "processFinished"
129
+ "type": enum_1.ChatEventType.PROCESS_FINISHED
128
130
  });
129
131
  },
130
132
  /**
@@ -133,19 +135,19 @@ const cbchat = {
133
135
  */
134
136
  sendConfirmationRequest: (confirmationMessage, buttons = [], withFeedback = false) => {
135
137
  return websocket_1.default.messageManager.sendAndWaitForResponse({
136
- "type": "confirmationRequest",
138
+ "type": enum_1.ChatEventType.CONFIRMATION_REQUEST,
137
139
  "message": confirmationMessage,
138
140
  buttons: buttons,
139
141
  withFeedback
140
- }, "confirmationResponse|feedbackResponse");
142
+ }, enum_1.ChatResponseType.CONFIRMATION_OR_FEEDBACK_RESPONSE);
141
143
  },
142
144
  askQuestion: (question, buttons = [], withFeedback = false) => {
143
145
  return websocket_1.default.messageManager.sendAndWaitForResponse({
144
- "type": "confirmationRequest",
146
+ "type": enum_1.ChatEventType.CONFIRMATION_REQUEST,
145
147
  "message": question,
146
148
  buttons: buttons,
147
149
  withFeedback
148
- }, "confirmationResponse|feedbackResponse");
150
+ }, enum_1.ChatResponseType.CONFIRMATION_OR_FEEDBACK_RESPONSE);
149
151
  },
150
152
  /**
151
153
  * Sends a notification event to the server.
@@ -153,7 +155,7 @@ const cbchat = {
153
155
  */
154
156
  sendNotificationEvent: (notificationMessage, type) => {
155
157
  websocket_1.default.messageManager.send({
156
- "type": "notificationEvent",
158
+ "type": enum_1.ChatEventType.NOTIFICATION_EVENT,
157
159
  "message": notificationMessage,
158
160
  "eventType": type
159
161
  });
@@ -1,16 +1,8 @@
1
- import { MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '../types/socketMessageTypes';
2
- import type { JSTreeStructureItem, JSTreeResponse } from '../types/InternalTypes';
3
- export type { JSTreeStructureItem, JSTreeResponse };
1
+ import { MatchProblemResponse, GetMatcherListTreeResponse, getMatchDetail } from '@codebolt/types/sdk';
4
2
  /**
5
3
  * A utility module for working with code.
6
4
  */
7
5
  declare const cbcodeutils: {
8
- /**
9
- * Retrieves a JavaScript tree structure for a given file path.
10
- * @param {string} filePath - The path of the file to retrieve the JS tree for.
11
- * @returns {Promise<JSTreeResponse>} A promise that resolves with the JS tree response.
12
- */
13
- getJsTree: (filePath?: string) => Promise<JSTreeResponse>;
14
6
  /**
15
7
  * Retrieves all files as Markdown.
16
8
  * @returns {Promise<string>} A promise that resolves with the Markdown content of all files.
@@ -1,121 +1,23 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
6
  const websocket_1 = __importDefault(require("../core/websocket"));
40
- const fs = __importStar(require("fs"));
41
- const path_1 = __importDefault(require("path"));
42
- const codeparser_1 = require("@codebolt/codeparser");
7
+ const enum_1 = require("@codebolt/types/enum");
43
8
  /**
44
9
  * A utility module for working with code.
45
10
  */
46
11
  const cbcodeutils = {
47
- /**
48
- * Retrieves a JavaScript tree structure for a given file path.
49
- * @param {string} filePath - The path of the file to retrieve the JS tree for.
50
- * @returns {Promise<JSTreeResponse>} A promise that resolves with the JS tree response.
51
- */
52
- getJsTree: async (filePath) => {
53
- try {
54
- // If no filePath is provided, we can't parse anything
55
- if (!filePath) {
56
- throw new Error('No file path provided for parsing');
57
- }
58
- // Get absolute path to ensure file can be accessed
59
- const absolutePath = path_1.default.resolve(filePath);
60
- // Check if file exists
61
- await fs.promises.access(absolutePath);
62
- // Get file extension to determine language parser
63
- const ext = path_1.default.extname(absolutePath).toLowerCase().slice(1);
64
- // Load appropriate language parser
65
- const languageParsers = await (0, codeparser_1.loadRequiredLanguageParsers)([absolutePath]);
66
- // Get parser for this file type
67
- const { parser, query } = languageParsers[ext] || {};
68
- if (!parser || !query) {
69
- throw new Error(`Unsupported language: ${ext}`);
70
- }
71
- // Read file content
72
- const fileContent = await fs.promises.readFile(absolutePath, 'utf8');
73
- // Parse file to get AST
74
- const tree = parser.parse(fileContent);
75
- // Get captures from the AST using the query
76
- const captures = query.captures(tree.rootNode);
77
- // Sort captures by position
78
- captures.sort((a, b) => a.node.startPosition.row - b.node.startPosition.row ||
79
- a.node.startPosition.column - b.node.startPosition.column);
80
- // Transform captures into a structured format
81
- const structure = captures.map((capture) => {
82
- const { node, name } = capture;
83
- return {
84
- type: name.includes('definition.') ? name.split('definition.')[1] : name,
85
- name: node.text,
86
- startLine: node.startPosition.row,
87
- endLine: node.endPosition.row,
88
- startColumn: node.startPosition.column,
89
- endColumn: node.endPosition.column,
90
- nodeType: node.type
91
- };
92
- });
93
- // Return response with the appropriate structure
94
- return {
95
- event: 'getJsTreeResponse',
96
- payload: {
97
- filePath: absolutePath,
98
- structure
99
- }
100
- };
101
- }
102
- catch (error) {
103
- // Return error response
104
- return {
105
- event: 'getJsTreeResponse',
106
- error: error instanceof Error ? error.message : String(error)
107
- };
108
- }
109
- },
110
12
  /**
111
13
  * Retrieves all files as Markdown.
112
14
  * @returns {Promise<string>} A promise that resolves with the Markdown content of all files.
113
15
  */
114
16
  getAllFilesAsMarkDown: () => {
115
17
  return websocket_1.default.messageManager.sendAndWaitForResponse({
116
- "type": "codeEvent",
117
- "action": "getAllFilesMarkdown"
118
- }, "getAllFilesMarkdownResponse");
18
+ "type": enum_1.EventType.CODE_EVENT,
19
+ "action": enum_1.CodeAction.GET_ALL_FILES_MARKDOWN
20
+ }, enum_1.CodeResponseType.GET_ALL_FILES_MARKDOWN_RESPONSE);
119
21
  },
120
22
  /**
121
23
  * Performs a matching operation based on the provided matcher definition and problem patterns.
@@ -126,14 +28,14 @@ const cbcodeutils = {
126
28
  */
127
29
  performMatch: (matcherDefinition, problemPatterns, problems = []) => {
128
30
  return websocket_1.default.messageManager.sendAndWaitForResponse({
129
- "type": "codeEvent",
130
- "action": "performMatch",
31
+ "type": enum_1.EventType.CODE_EVENT,
32
+ "action": enum_1.CodeAction.PERFORM_MATCH,
131
33
  payload: {
132
34
  matcherDefinition,
133
35
  problemPatterns,
134
36
  problems
135
37
  }
136
- }, "matchProblemResponse");
38
+ }, enum_1.CodeResponseType.MATCH_PROBLEM_RESPONSE);
137
39
  },
138
40
  /**
139
41
  * Retrieves the list of matchers.
@@ -141,9 +43,9 @@ const cbcodeutils = {
141
43
  */
142
44
  getMatcherList: () => {
143
45
  return websocket_1.default.messageManager.sendAndWaitForResponse({
144
- "type": "codeEvent",
145
- "action": "getMatcherList",
146
- }, "getMatcherListTreeResponse");
46
+ "type": enum_1.EventType.CODE_EVENT,
47
+ "action": enum_1.CodeAction.GET_MATCHER_LIST,
48
+ }, enum_1.CodeResponseType.GET_MATCHER_LIST_TREE_RESPONSE);
147
49
  },
148
50
  /**
149
51
  * Retrieves details of a match.
@@ -152,12 +54,12 @@ const cbcodeutils = {
152
54
  */
153
55
  matchDetail: (matcher) => {
154
56
  return websocket_1.default.messageManager.sendAndWaitForResponse({
155
- "type": "codeEvent",
156
- "action": "getMatchDetail",
57
+ "type": enum_1.EventType.CODE_EVENT,
58
+ "action": enum_1.CodeAction.GET_MATCH_DETAIL,
157
59
  payload: {
158
60
  matcher: matcher
159
61
  }
160
- }, "getMatchDetailResponse");
62
+ }, enum_1.CodeResponseType.GET_MATCH_DETAIL_RESPONSE);
161
63
  }
162
64
  };
163
65
  exports.default = cbcodeutils;
@@ -1,4 +1,4 @@
1
- import { MemorySetResponse, MemoryGetResponse } from '../types/socketMessageTypes';
1
+ import { MemorySetResponse, MemoryGetResponse, MemoryValue } from '@codebolt/types/sdk';
2
2
  /**
3
3
  * A module for handling in-memory database operations via WebSocket.
4
4
  */
@@ -6,10 +6,10 @@ declare const dbmemory: {
6
6
  /**
7
7
  * Adds a key-value pair to the in-memory database.
8
8
  * @param {string} key - The key under which to store the value.
9
- * @param {any} value - The value to be stored.
9
+ * @param {MemoryValue} value - The value to be stored.
10
10
  * @returns {Promise<MemorySetResponse>} A promise that resolves with the response from the memory set event.
11
11
  */
12
- addKnowledge: (key: string, value: any) => Promise<MemorySetResponse>;
12
+ addKnowledge: (key: string, value: MemoryValue) => Promise<MemorySetResponse>;
13
13
  /**
14
14
  * Retrieves a value from the in-memory database by key.
15
15
  * @param {string} key - The key of the value to retrieve.
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const enum_1 = require("@codebolt/types/enum");
6
7
  const websocket_1 = __importDefault(require("../core/websocket"));
7
8
  /**
8
9
  * A module for handling in-memory database operations via WebSocket.
@@ -11,16 +12,16 @@ const dbmemory = {
11
12
  /**
12
13
  * Adds a key-value pair to the in-memory database.
13
14
  * @param {string} key - The key under which to store the value.
14
- * @param {any} value - The value to be stored.
15
+ * @param {MemoryValue} value - The value to be stored.
15
16
  * @returns {Promise<MemorySetResponse>} A promise that resolves with the response from the memory set event.
16
17
  */
17
18
  addKnowledge: (key, value) => {
18
19
  return websocket_1.default.messageManager.sendAndWaitForResponse({
19
- "type": "memoryEvent",
20
- 'action': 'set',
20
+ "type": enum_1.EventType.MEMORY_EVENT,
21
+ 'action': enum_1.MemoryAction.SET_MEMORY,
21
22
  key,
22
23
  value
23
- }, "memorySetResponse");
24
+ }, enum_1.MemoryResponseType.SET_MEMORY_RESPONSE);
24
25
  },
25
26
  /**
26
27
  * Retrieves a value from the in-memory database by key.
@@ -29,10 +30,10 @@ const dbmemory = {
29
30
  */
30
31
  getKnowledge: (key) => {
31
32
  return websocket_1.default.messageManager.sendAndWaitForResponse({
32
- "type": "memoryEvent",
33
- 'action': 'get',
33
+ "type": enum_1.EventType.MEMORY_EVENT,
34
+ 'action': enum_1.MemoryAction.GET_MEMORY,
34
35
  key
35
- }, "memoryGetResponse");
36
+ }, enum_1.MemoryResponseType.GET_MEMORY_RESPONSE);
36
37
  }
37
38
  };
38
39
  exports.default = dbmemory;
@@ -1,4 +1,4 @@
1
- import { DebugAddLogResponse, OpenDebugBrowserResponse } from '../types/socketMessageTypes';
1
+ import { DebugAddLogResponse, OpenDebugBrowserResponse } from '@codebolt/types/sdk';
2
2
  export declare enum logType {
3
3
  info = "info",
4
4
  error = "error",